use strict; use warnings; our $a = "something"; if($a eq "taste") { print "\nNot equals"; } elsif($a eq m/ERROR/) { print "\nNot matches regex"; }
I wasted 15 mins trying to figure out what was wrong at line 6, because PERL told me to look there:
Use of uninitialized value $_ in pattern match (m//) at wtf.pl line 6.
Yes, I read that you should look around the block where PERL issues a warning message and not usually at the line number itself, but do understand that in real life the code which resulted in this error message was not so tiny as I have posted, neither were the number of conditions and/or branches... so visual inspection is not always very reliable neither productive..
Any suggestions on how to locate the snippet in error next time I face a similar error ?
For those still wondering, an 'eq' should be '=~'.. oh well..
In reply to Tracking down the line in error or warning by PoorLuzer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |