Re: How to change the comparsion criteria of diff?



On May 8, 11:18 am, Michael <Michael....@xxxxxxxxx> wrote:
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::Diff, Algorithm::Diff,
but didn't get any idea of it. I saw that one comparison method can be
passed into Algorithm::Diff 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!

To be more clearly on this question:
I need the script to ignore the text differences when the regex in one
file matches the corresponding part in the other. Thus I need to ask
the diff utility to compare two files with the new rules of regex as
shown above, which could be defined in a comparison function by user
self.

.



Relevant Pages

  • How to change the comparsion criteria of diff?
    ... I'm meeting the problem with diff methods in Perl. ... one containing regular-expression string ... normal regular expression does. ...
    (comp.lang.perl.misc)
  • Re: How to change the comparsion criteria of diff?
    ... I'm meeting the problem with diff methods in Perl. ... one containing regular-expression string ... normal regular expression does. ...
    (comp.lang.perl.misc)
  • Re: How to change the comparsion criteria of diff?
    ... I'm meeting the problem with diff methods in Perl. ... one containing regular-expression string ... normal regular expression does. ...
    (comp.lang.perl.misc)
  • Re: What do you need to have to be considered a Master at Perl?
    ... Someone who understands the Chomsky hierarchy, ... I don't think perl actually existed back then. ... "I've learnt how to match balanced parentheses with regular expressions." ... I don't care if perl regular expressions are or aren't kosher. ...
    (comp.lang.perl.misc)
  • Re: Regular expression help
    ... expression in english is a daunting task for me. ... Redefine your approach to regular expressions. ... Perl documentation, study the examples given (not only by ...
    (comp.lang.perl.misc)