XP is just a number | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Internally speaking, the problem is because only "control ops" (Cop's) have a line number recorded with them. To Perl, an if-elsif-else sequence is one big logical operator, and that statement starts on a specific line. If there's a problem evaluating something in the operator itself, the line number the statement starts on is used. That's why
will warn that there's an uninitialized value at line 1 (even though it's at line 4), but it will properly tell you about the uninitialized value on line 5 (because each new statement in Perl is a new Cop). A similar problem is found in this case: Even though the code spans five lines, error messages will refer to the line the statement started on. It's not going to be easy to fix this bug, methinks. Update: but a good kludgy work-around is to use a do { ; ... } block! That properly reports the warning for line 2. It's super-kludge, though.
_____________________________________________________ In reply to Re: if-elsif weirdness
by japhy
|
|