Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I can confirm that perl 5.8 has exactly the problem you state in terms of citing the "wrong" line number -- on both solaris and (suse) linux. But I haven't found a way to make it do the "right" thing (not even with "# line N" comments, described in perlsyn) -- however the perlsyn man page does have a fair bit to say about using "SWITCH:" and "use Switch;"...

update: Here's a version where I tried (and failed) to get correct line numbers reported for the error:

#!/usr/bin/perl -w use strict; my $string = "ABC"; my $value = undef; if ($string =~ qr(DEF)) { # warning reported here print "foo"; } # line 8 elsif ($string =~ qr(GHI)) { print "bar"; } # line 11 elsif ($value/1000 ne $value) { # warning actually here print "baz"; } else { }
The line with "$value/1000" is still reported by perl 5.8 as "line 5" (where the "if()" block begins). If I put "#line 11" above the start of the "if()" block, then perl picks it up, and presumably any error in any of the conditions would be reported as happening at line 11. That's not much help. (I haven't checked to see whether line-number reporting would work any better with a "switch"-style block -- I guess that might not be a sure thing...)

In reply to Re: if-elsif weirdness by graff
in thread 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 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? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2021-07-23 18:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?