Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Confusing warning with if/elsif/else

by fergal (Chaplain)
on Dec 08, 2005 at 10:40 UTC ( [id://515201]=note: print w/replies, xml ) Need Help??


in reply to Confusing warning with if/elsif/else

Why are you blaming strict? Delete use strict and the problem still appears.

The problem is perl's parser/interpretter which doesn't properly record the line number of the various bits of an if. Consider:

#! /usr/bin/perl my $a = "foo"; if ( $a =~ m/aa/ ) { print "hello"; } elsif ( nonexistant() ) { print "hello"; } else { }

Which says

Undefined subroutine &main::nonexistant called at - line 4.

Basically everything in the conditions of an if statement appears to be on the same line as the if.

It sucks but it's a known issue and not likely to be fixed any time soon. If I recall correctly, the way perl currently works, to fix this would mean that each block in the if would require it's own stack frame, which is too much overhead.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://515201]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-04-18 19:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found