Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Tweaking 'return'.

by ChemBoy (Priest)
on Nov 22, 2005 at 21:53 UTC ( [id://510932]=note: print w/replies, xml ) Need Help??


in reply to Tweaking 'return'.

It's conceivable that you could (though I'm somewhat doubtful), but it might be easier, if this is for debugging, to wrap your subroutines, roughly thus (largely untested):

sub dosomething {print "in dosomething\n" } sub wrappit { no strict 'refs'; my ($subname) = @_; my $oldsub = \&{$subname}; *{$subname} = sub { print "entering $subname\n"; my @rv = wantarray ? $oldsub->(@_) : scalar $oldsub->(@_); print "leaving $subname\n"; return wantarray ? @rv : $rv[0]; }; } wrappit('dosomething'); dosomething(1..5);



If God had meant us to fly, he would *never* have given us the railroads.
    --Michael Flanders

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-04-16 21:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found