Passing an empty string in $_ creates an empty regexp pattern, as in "m//". This is a special case discussed in perlop, here:
The empty pattern //
If the PATTERN evaluates to the empty string, the last successfully matched regular expression is used instead.....If no match has previously succeeded, this will (silently) act instead as a genuine empty pattern (which will always match).
Your first match occurs in that vacuum of acting like a genuinely empty pattern, which will always match. The final test is like asking if "" =~ m/foo/, which doesn't match.
Dave
In reply to Re: grep trouble
by davido
in thread grep trouble
by LogMiner
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |