http://www.perlmonks.org?node_id=967101

naturalsciences has asked for the wisdom of the Perl Monks concerning the following question:

A funny thing happened to me today. I created a little piece to check weather a text file has multiple same lines.

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

So I thought it should work fine unless the first line would be "seed" in which case it would also printed out. To test this I created a text file which had first line "seed". Funny .. but the code found out all the actual redundant lines and did not declare the first line to be redundant. (which actually is a good thing I guess).

But as I look and look at this simple piece of code I cannot in my mind understand why the first match (which should be between array elements "seed" and "seed") doesn't evaluate true)

Can anyone enlighten me?