There's more than one way to do things | |
PerlMonks |
Re: Matching against $_ behaves differently than matching against a named scalar?by stevieb (Canon) |
on Apr 20, 2020 at 16:44 UTC ( [id://11115837]=note: print w/replies, xml ) | Need Help?? |
choroba answered the why, I'll give a different way to do things. Instead of checking the condition of the variables after the fact, do it before hand:
Also note the die() statement if the file can't be opened, and the use of 3-arg open(). One last thing... in your former example, you're missing the + in the regex.
In Section
Seekers of Perl Wisdom
|
|