in reply to Re: Self resurrecting perl scripts
in thread Self resurrecting perl scripts
END happens after the die..
#!/usr/bin/perl -w $SIG{__DIE__} = sub { print "Dead\n"; }; die "Blah"; END { print "This is the end, my friend.\n"; }
Outputs:
Dead blah at ./foo.pl line 5. This is the end, my friend.
But, you need to define the SIG before you use it. The END will happen regardless. For example:
#!/usr/bin/perl -w die "Blah"; $SIG{__DIE__} = sub { print "Dead\n"; }; END { print "This is the end, my friend.\n"; }
Will output:
Blah at ./foo.pl line 3. This is the end, my friend.
Cheers,
KM
|
|---|