Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

RE: (jcwren) Re: (2) Tying events to perl warnings and errors

by reptile (Monk)
on Sep 14, 2000 at 00:23 UTC ( #32355=note: print w/ replies, xml ) Need Help??


in reply to (jcwren) Re: (2) Tying events to perl warnings and errors
in thread Tying events to perl warnings and errors

Localize the handler with a closure, like this:

sub foo { my ($a, $b, $c) = @_; my %hash = (a => {b => {c => 0}}); # whatever other variables you want to initialize local $SIG{__WARN__} = sub { # dump those variables here }; print $hash{$a}->{$b}->{$c}; # ... }

The variables you want to dump will be in scope of the __WARN__ handler and you can do whatever you like with them.

local $_ = "0A72656B636148206C72655020726568746F6E41207473754A"; while(s/..$//) { print chr(hex($&)) }


Comment on RE: (jcwren) Re: (2) Tying events to perl warnings and errors
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2014-07-24 00:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (155 votes), past polls