Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Is this BEGIN construct supposed to work?

by ikegami (Pope)
on Nov 02, 2011 at 23:47 UTC ( #935521=note: print w/ replies, xml ) Need Help??


in reply to Is this BEGIN construct supposed to work?

Maybe you want state?

sub routine { state %hash = ...; ... %hash ... }

It's kinda like the following, but the assignment is actually done the first time state is evaluated.

my %hash; BEGIN { %hash = ...; } sub routine { ... %hash ... }


Comment on Re: Is this BEGIN construct supposed to work?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2015-07-07 11:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (88 votes), past polls