I asked a question a couple of days back on perl beginners at Yahoo groups as well on 
other forums.
to compare two text files/strings and to print the results if both are different and 
was advised to use Text::Diff.

Actually, I am working on project of transcription, where typist types the $text1 and 
save it. Then the QA (Quality Control) person logs in and make appropriate corrections 
to file and save it again as $text2. Now I have to compare $text1 with $text2 for the 
feedback of typist, so that he can view the changes QA made to the file and should not 
repeat the same in the next files.

So far so good, I used the Text::Diff and it solved my problem, when I tested it for 
small text containing  3 - 4 lines paragraph. Now the problem arises again. I tested 
it for 3-4 lines paragraph, but when script went live, the text strings were quite big 
like some contained 20 lines in a single paragraph. Text::Diff matches until \n || \r 
is inserted. Okay, the module is doing it's job well I have no problems with it. Now 
the problem is if only QA changes 'is' to 'was' or removes any white space character 
in 20 lines. Text::Diff prints the whole 20 lines because the changes were made. So 
sometime typist reads whole 20 lines and found nothing in it except for removal of 
white space which obviously he is unable to see or sometime only 'is' to 'was' change 
(if the file contains no other big mistakes). So instead of helping the typist to 
review the feedback from QA, it becomes a time waster.

Now, I am looking for a way where I can highlight (by enclosing changes with 
<B></B>tags) the changes (if the $text2 is different from $text1) either within the 
output of Text::Diff or separately from it. 

TIA,

Sara.


-------------------------------------------------------------
#!/usr/bin/perl


use Text::Diff;
use strict;
use warnings;
use CGI::Carp qw(fatalsToBrowser);
use CGI;
my $q = new CGI;

my $text1 = $q->param('text1') || 'this is text line and it contains the ___ line';
my $text2 = $q->param('text2') || 'this is text line and it contains no blank line';


print $q->header();


my @output;

my $diff = diff \$text1, \$text2, { STYLE => "Context",
OUTPUT => [EMAIL PROTECTED],
CONTEXT => 0,
};

print "@output";


Reply via email to