Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: help using packForget()

by jonadab (Parson)
on Apr 28, 2007 at 15:36 UTC ( #612560=note: print w/ replies, xml ) Need Help??


in reply to Re: help using packForget()
in thread help using packForget()

the idea of local $boom is to give the global $boom a local value so when you speak of $boom, here, it's a package global.

This description, if not outright wrong, is at least misleading. The idea of local is to give the global variable a dynamic value for the time being, but allow it to be automagically restored to its former value later (when the current block exits). The distinction is important, because the dynamic value is global in nature, not local in the traditional sense. (Yes, local is misnamed.) Any other code that gets called, even from other packages, will see the dynamic value. Therein lies its value. In fact, you would ordinarily not use local on your own variables. For those you would typically use my or our or place them in a package namespace. local is more useful for dynamically scoping the package variables used by other code that you are calling, in order to adjust its behavior in some way. (In Perl this is most often special variables belonging to built-in code that is part of perl itself, but in principle it could also be global (or package) variables belonging to a module, as is common e.g. in elisp.)

-- 
We're working on a six-year set of freely redistributable Vacation Bible School materials.


Comment on Re: help using packForget()

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (14)
As of 2014-08-29 12:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (280 votes), past polls