Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2024-04-26 06:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found