Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: scope and declaration in local packages

by december (Pilgrim)
on Jan 31, 2011 at 13:24 UTC ( #885267=note: print w/replies, xml ) Need Help??


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

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

I used the "ref instance constructor" this time because I've seen it around and it seemed like a nice extra feature to have. I doubt if it's really useful to my code, though... Probably it's cleaner without.

  • Comment on Re^2: scope and declaration in local packages

Replies are listed 'Best First'.
Re^3: scope and declaration in local packages
by ikegami (Patriarch) on Jan 31, 2011 at 15:50 UTC

    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://885267]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2022-01-17 17:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (51 votes). Check out past polls.

    Notices?