in reply to Reqex from two files and compare
you could have this instead:# is it a range or a single line? if ($info =~ /(\d+)-(\d+)/) { $changes{$file} = [$1, $2]; } else { $changes{$file} = [$info]; }
This way, each value in %changes is a string of space-separated line numbers, including every line that has changed in a given file, and by using ".=", the string just gets longer each time the same file is mentioned again in changes.txt. Now, when you check this against the "data.txt" listing, instead of aersol's two-way test, you have a single test for all cases:if ($info =~ /(\d+)-(\d+)/) { $changes{$file} .= " ".join(" ",($1 .. $2))." "; } else { $changes{$file} .= " $info "; }
... if (defined $changes{$file}) { # skip if this $line isn't mentioned in $changes next unless ($changes{$file} =~ / $line /); } ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Reqex from two files and compare
by DS (Acolyte) on Jul 17, 2002 at 05:03 UTC |