Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: How to best pass on the context / wantarray?

by demerphq (Chancellor)
on Mar 27, 2006 at 16:30 UTC ( #539477=note: print w/replies, xml ) Need Help??


in reply to How to best pass on the context / wantarray?

Context propagates.

sub handle_mutator { my ($self,$cb)=@_; my $obj; if (defined wantarray) { $obj = $self->copy(); } else { $obj = $self; }; $cb->($obj,@_); } sub something { shift->handle_mutator(sub{ .... }); }
---
$world=~s/war/peace/g

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (1)
As of 2016-12-04 08:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (63 votes). Check out past polls.