PoorLuzer has asked for the wisdom of the Perl Monks concerning the following question:
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..
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tracking down the line in error or warning
by ikegami (Patriarch) on Mar 24, 2009 at 13:10 UTC | |
|
Re: Tracking down the line in error or warning
by VinsWorldcom (Prior) on Mar 24, 2009 at 13:12 UTC | |
by RyuMaou (Deacon) on Mar 24, 2009 at 13:52 UTC | |
by PoorLuzer (Beadle) on Mar 24, 2009 at 14:10 UTC |