Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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?


In reply to if-elsif weirdness by leriksen

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-25 07:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found