in reply to Compare2Files LinebyLine
As a brief example, the core of your program can be:
I used this technique in a recent post as well, and you might see it clearer there.my %compare; my %files = ( a => 'oldfile', b => 'newfile' ); # compare oldfile to n +ewfile for my $filekey (keys %files) { open F, $files{$filekey} or next; while (<F>) { next if /^(#.*)\s*$/; # ignore blanks and comments $compare{lc $_} .= $filekey; } } print "Lines in newfile but not oldfile:\n", sort grep $compare{$_} !~ /a/, keys %compare; print "Lines in oldfile but not newfile:\n", sort grep $compare{$_} !~ /b/, keys %compare;
-- Randal L. Schwartz, Perl hacker
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Compare2Files LinebyLine
by thesundayman (Novice) on Sep 26, 2001 at 21:05 UTC | |
by merlyn (Sage) on Sep 27, 2001 at 00:59 UTC | |
by thesundayman (Novice) on Sep 27, 2001 at 16:06 UTC | |
by zoot (Initiate) on Feb 17, 2003 at 20:25 UTC | |
by BrowserUk (Patriarch) on Feb 17, 2003 at 21:21 UTC |