Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://612560]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (11)
As of 2018-06-22 20:01 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (124 votes). Check out past polls.