in reply to Re: my code works just fine, but how :D
in thread my code works just fine, but how :D

Not true. A first line of "|\n" would also match, for example. Fix:
my @comp = "seed\n"; # Fix 1 while ($line = <>) { push(@comp, $line); print $line if $comp[0] =~ /^\Q$comp[1]\E\z/; # Fix 2 shift(@comp); }

But why not just use eq?

my @comp = "seed\n"; while ($line = <>) { push(@comp, $line); print $line if $comp[0] eq $comp[1]; shift(@comp); }

Simpler still:

my $last = ""; while (<>) { print if $_ eq $last; $last = $_; }

Replies are listed 'Best First'.
Re^3: my code works just fine, but how :D
by aaron_baugher (Curate) on Apr 25, 2012 at 18:05 UTC