do i need to use a counter, or say "if $foo ne $previousfoo", or is there any easier way?You don't necessarily need to do that - you are using perl after all ...
However it's probably easier just to keep your state in a variable as it's straight forward and doesn't require the slurping of the whole file.open(my $fh, "somefile.txt") or die("ack - $!"); my @lines = <$fh>; # let's hope this isn't a large file ... for (0 .. $#lines) { print "a change - $lines[$_]" if $lines[$_] ne $lines[$_ - 1]; }
_________
broquaint
In reply to Re: At each change in...
by broquaint
in thread At each change in...
by malaga
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |