Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Closure question

by broquaint (Abbot)
on Mar 02, 2004 at 17:44 UTC ( #333314=note: print w/replies, xml ) Need Help??


in reply to Closure question

This is the nature of the execution flow of perl - my @r hasn't been 'executed' yet, so you'll want something along the lines of a BEGIN block if you want it to be initialized and have it after the subroutine call e.g
foo(); BEGIN { my $str = 'a string'; sub foo { print "\$str is $str\n" } } __output__ $str is a string
HTH

_________
broquaint

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2021-12-02 03:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    R or B?



    Results (17 votes). Check out past polls.

    Notices?