in reply to RE: RE: Setting up signal handlers for an object with access to $self
in thread Setting up signal handlers for an object with access to $self

Because I like CODE refs way too much:
sub set_signal_handlers { my $self = shift; if (!%handlers) { # Class signal handler, only set the first time $SIG{USR1} = \&class_handle_USR1; } # You could index by $self->name, or by any other identifier $handlers{$self} = $self->handle_USR1(); } # skip a few sub handle_USR1 { my $self = shift; return sub { print "handling USR1 for ", $self->name, "\n"; } }
That fits all of my definitions of beautiful.
  • Comment on RE: RE: RE: Setting up signal handlers for an object with access to $self
  • Download Code