Re: How to change the comparsion criteria of diff?
- From: Michael Yang <Michael.Yxf@xxxxxxxxx>
- Date: 7 May 2007 23:47:20 -0700
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.
.
- Follow-Ups:
- Re: How to change the comparsion criteria of diff?
- From: Michael Yang
- Re: How to change the comparsion criteria of diff?
- References:
- How to change the comparsion criteria of diff?
- From: Michael
- How to change the comparsion criteria of diff?
- Prev by Date: Re: Link Matching
- Next by Date: FAQ 5.22 All I want to do is append a small amount of text to the end of a file. Do I still have to use locking?
- Previous by thread: How to change the comparsion criteria of diff?
- Next by thread: Re: How to change the comparsion criteria of diff?
- Index(es):
Relevant Pages
|