in reply to if-elsif weirdness

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
if ($x) { print 1; } elsif ($x != 2) { print $y; }
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:

print 1, 2, 3, undef, 4;
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!

if ($x) { ... } elsif (do {; $x == 2}) { ... }
That properly reports the warning for line 2. It's super-kludge, though.

Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;