in reply to DIE handling ... carp!

Hi rootcho,

Specifically, here's an example of a program trapping the "die", and continuing if desired. Note the eval which ambrus and cowboy mentioned, wrapping the entire while clause:

use strict; use warnings; # Globals my $num = 1_000_000_000; # Signal handling $SIG{__DIE__} = sub { trap_otherwise_fatals() }; # Main program sure_to_fail(); print "Continuing anyway\n"; # ... more code here if desired ... # Subroutines sub trap_otherwise_fatals { print "** Would have died at num = $num **\n"; } sub sure_to_fail { eval { while (1) { my $log = log($num); printf "Log(%12d) = %10.6f\n", $num, $log; $num = $log; } } }

s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/