Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: An eighth use of local

by Ovid (Cardinal)
on Dec 01, 2005 at 19:27 UTC ( #513394=note: print w/ replies, xml ) Need Help??


in reply to An eighth use of local

My most common use of local deals with recursive method calls:

sub foo { my $self = shift; local $self->{some_val} = $self->get_val; # do a bunch of stuff $self->foo; }

This seems strange, but I do find this useful at times. It allows me to temporarily overwrite a value which needs to be preserved for a given stack frame.

Cheers,
Ovid

New address of my CGI Course.


Comment on Re: An eighth use of local
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (13)
As of 2015-07-07 19:11 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 (93 votes), past polls