go ahead... be a heretic | |
PerlMonks |
Re: if-elsif weirdnessby hossman (Prior) |
on May 21, 2003 at 07:03 UTC ( [id://259659]=note: print w/replies, xml ) | Need Help?? |
Assuming I understand your question, you're looking for a generic "Best Practices" rule you can apply to using "if-elsif" to ensure that *if* you have a warning (or die)in the "EXPR" of (one of) the elsif, *then* the line number reported for that warning (or death) will be accurate. Is that correct? Assuming youre requirement is to keep using if-elsif, then i don't think there's anything you can do -- short of waiting for a new version of perl that does a better job of reporting the line number. One thing you can do, is replace all occurences of this... elsif (EXPR) BLOCK...with this... else { if (EXPR) BLOCK } Using the test case from Node #42078 as an base for an example, use this instead... That should accurately cite the warning on Line 7. Personally, I don't think it's really that big a deal .. just make sure you keep in mind this problem for the future, and if you ever notice any warnings/deaths cited with a line number of some "if (EXPR)" code, then skim down and see if there's an "elsif" that might be the real culprit.
In Section
Seekers of Perl Wisdom
|
|