This bug is just a minor annoyance, but it can slow down debugging if one is not aware of it, so I thought I'd share. The following snippets illustrates it:
If you run it as written, the output is:if ( 0 ) { ; } elsif ( die __LINE__ ) { ; }
Note that the line reported by die is incorrect. The same bug exists with warn, and with warnings in general. E.g.4 at buggy.pl line 1.
use warnings; if ( 0 ) { ; } elsif ( "$_" ) { ; } __END__ Use of uninitialized value in string at buggy.pl line 2.
Stuff happens.if ( 0 ) { ; } elsif ( 0/0 ) { ; } __END__ Illegal division by zero at buggy.pl line 4
Update: the above examples were run with perl 5.8.6. I haven't looked at other versions. YMMV.
Update 2: thanks to merlyn for the clarification on compile-time vs. run-time behavior, which I originally mis-interpreted as a difference in response between non-fatal and fatal and non-fatal errors.
the lowliest monk
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: die/warn bug in elsif
by merlyn (Sage) on Jan 12, 2006 at 17:29 UTC | |
by radiantmatrix (Parson) on Jan 13, 2006 at 15:04 UTC | |
Re: die/warn bug in elsif
by Steve_p (Priest) on Jan 19, 2006 at 01:11 UTC |
Back to
Meditations