Insert text and compare to prove the insertion

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View


I am busy with some conversion for which perl is the best way to do it
I guess. I am converting from back from some sort of zipfile to plain
text. That can only be done with a tool from the supplier. The next
step is to insert some text in the reportnames. I have the following
command for that:
perl -p -i.orig -e "BEGIN {@ARGV = map { glob } @ARGV } s/REPORT:
/REPORTTEST: /g" *.txt

That works fine. It updates all the reportnames in all the textfiles
correctly. But, as part of the conversion I have to create a report of
the changes before importing it in the new system. Thats where I am
having problems. The process has to run without human interference from
legal point of view. I am compare the reports one by one by windiff,
but I can not automate that. So, I created a listing from the report
files with dir *.txt /b > input.bat with good old dos. Then I run a
perl script to insert the windiff command to compare, put the results
in a txt file and exit:
perl -p -i.orig -e "s/^/windiff -Fx compare.txt . .\test2\ /"
However, windiff overwrites the compare.txt file. So, I need to do the
compare differently (not windiff) or be able to created unique
(=sequenced) output files.

My knowledge of perl is just not good enough to be able to trigger this
problem. I hope there is someone who can give some tips or some help to
trigger this for me nasty problem. The maximum number of files should
be 500 per run.

Your help is appreciated!!


Re: Insert text and compare to prove the insertion

Quoted text here. Click to load it

What about a human that "assists" rather than "interferes"?

Would that be OK?

Or maybe you meant "without human involvement" instead?

Quoted text here. Click to load it

If only you could find a library of Perl code where your problem
has already been solved by somebody who _can_ write Perl...

Quoted text here. Click to load it

... search CPAN for already-invented wheels:

    Tad McClellan                          SGML consulting                   Perl programming
    Fort Worth, Texas

Re: Insert text and compare to prove the insertion

Well, Tad, many thanks for your helpfull reply. Just to clarify, with
the process NO human involvement/assistence/interference/hand is
allowed. That's why it has to be done automated.

Of course I knew about CPAN and of course I have been searching in
there (did I mention I had a Perl course at IBM about 2 years ago...),
but like I mentioned, my knowledge of Perl is just not good enough to
trigger this, even with

Oh well, I have triggered it in a different way now, which for future
reference I will put in here.

I have created 2 good old msdos batch files:
Batchfile one (the one I call):
perl -p -i.orig -e "BEGIN {@ARGV = map { glob } @ARGV } s/REPORT:
/TESTREPORT: /g" *.txt
dir *.txt /b > input.bat
perl -p -i.orig -e "s/^/call diffwin /" input.bat
call input.bat
del input.bat

Batchfile 2 (diffwin):
windiff -Fx %1.diff .\%1 .\%1.orig

It works as follows:
search and replace the string
List the directory contents of files with txt to a file (called
insert at the beginning of each line in input.bat the string call
call the input.bat file, which calls diffwin.bat with as a parameter
the converted filename.
Diffwin.bat performs a windiff compare and puts the output in a unique
file per compare.

I hope this is usefull for someone. My problem is now at least solved.


Site Timeline