!unlike has asked for the wisdom of the Perl Monks concerning the following question:
Hi All,
In a nutshell my question is this: how do you get a signal handler to print the contents of a lexically scoped variable?
For those who need a code example please view the following as a summary of the problem
$SIG{INT} = sub { die "borked on $var"; }; alarm(1); while(1) { my $var = "wibble"; } alarm(0);
Now that is an extreeme example as sigint will be called everytime. But I think it makes my point.
When ran under use strict I get the following error message:
Global symbol "$var" requires explicit package name...
Other than putting this var into global scope is there anyway I can pass the var to the signal handler?
TIA
!unlike
I write my Perl code like how I like my sex: fast and dirty. ;)
Back to
Seekers of Perl Wisdom