A looonnnggg time ago somebody noted
this
well I just wasted an hour with the same, but I can add that it works OK on our Solaris 5.005, but not RH 5.6.0 or RH 5.6.1 - no idea on 5.8 (anyone?)
#!/usr/bin/perl -w
use strict;
my $string = "ABC";
my $value = undef;
if ($string =~ qr(DEF)) { # warning reported here
} elsif ($string =~ qr(GHI)) {
} elsif ($value/1000 ne $value) { # warning actually here
} else {
}
Use of uninitialized value in division (/) at E:\src\perl\error.pl line 5.
Use of uninitialized value in string ne at E:\src\perl\error.pl line 5.
now, apart from long chains of if-elsif's being a pain and possibly a sign of poor design or implementation, we all know perfectly well that we all do it all the time - so is there a way to 'nudge' perl into reporting the correct line in the warning? Or would I be better off using some switch/case variant from now on?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.