in reply to Perl delete function
It's still not clear what exactly you want, but maybe you want a line by line comparison of the files? If so, the following will help you along:
use strict; use warnings; open my $fh1, '<', 'text1' or die $!; open my $fh2, '<', 'text2' or die $!; while (!eof($fh1) && !eof($fh2)) { chomp( my $line1 = <$fh1> ); chomp( my $line2 = <$fh2> ); if ($line1 eq $line2 ) { print "Match for $line1\n"; } else { print "Difference for $line1, $line2\n"; } } if (! eof($fh1)) { warn "Still more data in file handle 1\n"; } if (! eof($fh2)) { warn "Still more data in file handle 2\n"; } close($fh1); close($fh2);
- Miller
* Edited to add validation for equal length files.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Perl delete function
by annel (Novice) on Dec 23, 2013 at 07:10 UTC | |
by wind (Priest) on Dec 23, 2013 at 07:36 UTC | |
by annel (Novice) on Dec 23, 2013 at 07:45 UTC |
In Section
Seekers of Perl Wisdom