#!/opt/perl/bin/perl use strict; use warnings; use Data::Dumper; print "set handler 1\n"; $SIG{ALRM} = sub { print "handler 1\n"; }; print "set handler 2\n"; $SIG{ALRM} = sub { print "handler 2\n"; }; print "set handler 3 (local)\n"; { local $SIG{ALRM}; print "\$SIG{ALRM} is now local: " . Dumper($SIG{ALRM}); $SIG{ALRM} = sub { print "handler 3\n"; }; print "\$SIG{ALRM} is now set locally: " . Dumper($SIG{ALRM}); }