On line 23 you have "my $pl = ''". You probably intend to use that variable to hold the "previous line." But it's never being set to anything within the while loop.
The standard algorithm is something like this:
my $prev; while( my $curr = <$infile> ) { chomp $curr; if( defined $prev && $curr eq $prev ) { # Take some action. } $prev = $curr; }
If you need to report the line number within the file of the contents of $prev, it's always going to be $.-1.
Dave
In reply to Re: Previous Line Matching Issues
by davido
in thread Previous Line Matching Issues
by ImJustAFriend
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |