!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. ;)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: lexical variables and signal handlers
by fglock (Vicar) on May 27, 2003 at 14:47 UTC | |
by !unlike (Beadle) on May 27, 2003 at 14:49 UTC | |
Re: lexical variables and signal handlers
by Lachesis (Friar) on May 27, 2003 at 14:52 UTC | |
Re: lexical variables and signal handlers
by broquaint (Abbot) on May 27, 2003 at 14:50 UTC | |
Re: lexical variables and signal handlers
by Elian (Parson) on May 27, 2003 at 15:47 UTC |
Back to
Seekers of Perl Wisdom