M
Michael
Hi all:
I'm meeting the problem with diff methods in Perl.
I am comparing two files, one containing regular-expression string
texts, and the other doesn't. what I need to do is to find the
difference between EXCEPT FOR when regular expression matches with the
other's corresponding text, which is shown as below,
For example:
A.txt: Hello every one! I like .* languages very much!
B.txt: Hello every one! I like Perl Languages very much!
The regexp ".*" in A.txt is used to match any string in B.txt as the
normal regular expression does. Here A.txt and B.txt are considered
equal. But the general diff method would consider them as difference
with line-by-line text comparison. And if there are different, I want
the output with same behavior as in the UNIX.
I searched into the modules of Perl, like Text:iff, Algorithm:iff,
but didn't get any idea of it. I saw that one comparison method can be
passed into Algorithm:iff as the new comparison criteria in the doc
online, but failed after trying. Could any one give a simple example
showing this feature?
my (@seq1, @seq2) = (<FH1>, <FH2>);
diff(\@seq1, \@seq2, $comparison_function);
I don't know what is the rules of designing this $comparison_function?
If there is some other way to do this, please kindly tell me, thanks
very much!
I'm meeting the problem with diff methods in Perl.
I am comparing two files, one containing regular-expression string
texts, and the other doesn't. what I need to do is to find the
difference between EXCEPT FOR when regular expression matches with the
other's corresponding text, which is shown as below,
For example:
A.txt: Hello every one! I like .* languages very much!
B.txt: Hello every one! I like Perl Languages very much!
The regexp ".*" in A.txt is used to match any string in B.txt as the
normal regular expression does. Here A.txt and B.txt are considered
equal. But the general diff method would consider them as difference
with line-by-line text comparison. And if there are different, I want
the output with same behavior as in the UNIX.
I searched into the modules of Perl, like Text:iff, Algorithm:iff,
but didn't get any idea of it. I saw that one comparison method can be
passed into Algorithm:iff as the new comparison criteria in the doc
online, but failed after trying. Could any one give a simple example
showing this feature?
my (@seq1, @seq2) = (<FH1>, <FH2>);
diff(\@seq1, \@seq2, $comparison_function);
I don't know what is the rules of designing this $comparison_function?
If there is some other way to do this, please kindly tell me, thanks
very much!