in reply to Re: trap signal 'exit': why I am not able to have it work??
in thread trap signal 'exit': why I am not able to have it work??

you can't switch "exit" handlers midstream, and you can't unregister END{} blocks,

But you can enable or disable code in the END blocks by using flag variables:

>cat demo.pl #!/usr/bin/perl use v5.12; use warnings; our $endFlag; END { if ($endFlag) { say "End flag is set, have to so some cleanup"; say "Wash, rinse, repeat" for 1..5; } else { say "Nothing to do"; } } $endFlag = $ARGV[0]; say "How will this end?"; >perl demo.pl 0 How will this end? Nothing to do >perl demo.pl 1 How will this end? End flag is set, have to so some cleanup Wash, rinse, repeat Wash, rinse, repeat Wash, rinse, repeat Wash, rinse, repeat Wash, rinse, repeat >

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)