Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re^3: scope and declaration in local packages

by ikegami (Patriarch)
on Jan 31, 2011 at 15:50 UTC ( [id://885299]=note: print w/replies, xml ) Need Help??

in reply to Re^2: scope and declaration in local packages
in thread scope and declaration in local packages

I didn't realise that the function vs. variable "declaration" happens in different stages.

Function and variable declarations both happen at compile time. You wouldn't have been able to compile the function if that wasn't the case. How can it use a variable that doesn't exist?

Assignments, on the other hand, happen at run-time. That's why the following code works:

>perl -E"for (qw( a b )) { my $x = $_; say $x }" a b

Log In?

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-22 16:51 GMT
Find Nodes?
    Voting Booth?

    No recent polls found