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

Re^6: closure clarity, please

by JadeNB (Chaplain)
on Dec 07, 2009 at 16:39 UTC ( #811543=note: print w/replies, xml ) Need Help??


in reply to Re^5: closure clarity, please
in thread closure clarity, please

Here's another way of demonstrating the effect in your sample code, with hopefully a bit less “magic gluing”:
sub g { my ( $a ) = @_; sub f { $a }; return sub { $a = $_[0] }; } push my @setters, g("Hi\n"), g("Bye\n"); print f; # => Hi $setters[0]("Bye\n"); print f; # => Bye $setters[1]("Hi\n"); print f; # => Bye (still)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://811543]
help
Chatterbox?
[Lady_Aleena]: That's the problem. I have 29 scripts, 3 modules, and gads of data I am thinking about deleting out of anger over an API change that made all of those things worthless.

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2017-05-25 07:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?