horrendo has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks,
I'm trying to clean up some existing code to pass perlcritic.
One of the common 'styles' is to have a separate method to trap signals. For example :
sub trap_signals { $SIG{CHLD} = \&handler; :
Now, perlcritic wants me to make a local copy of $SIG (as per page 81 of Perl Best Practices). However in this case the local copy defeats the purpose.
I can of course do something like :
sub trap_signals { my $sig = \%SIG; $sig->{CHLD} = \&handler; :
It passes perlcritic but this seems to me to make the code more obscure and no 'safer'.
Is there a 'preferred' approach for dealing with this situation?
Thanks a lot.
H.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Doing the right thing by perlcritic
by ikegami (Patriarch) on May 26, 2010 at 04:18 UTC | |
by horrendo (Sexton) on May 26, 2010 at 04:34 UTC | |
by ahmad (Hermit) on May 26, 2010 at 10:36 UTC | |
|
Re: Doing the right thing by perlcritic
by bluescreen (Friar) on May 26, 2010 at 23:59 UTC |