#!/bin/perl sub trp_h{ print "\nIn 'trp_h()'. ". "\nReceived parameters \@_: ".(join ", ",@_). "\n\$! as a number: ".($!+0).", as a string: ".(" ".$!). "\n now 'sleep 5' before return."; sleep 5; } $SIG{EXIT}='trp_h'; print "\nSet handler: $SIG{EXIT}\n"; exit(5); print "after first exit"; $SIG{EXIT}=\&trp_h; print "\nSet handler to code: $SIG{EXIT}\n"; exit(3); print "after second exit\n"; print "Restoring to default\n"; $SIG{EXIT}='DEFAULT'; exit(2); exit 1;