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 ( #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? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2022-05-25 17:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (90 votes). Check out past polls.

    Notices?