The compiler is catching the division by zero before your code has any opportunity to tackle it. I made the following work: #!/usr/bin/env perl
use Exception::Class ( 'MyException' );
# try
my $z = 0;
eval {
eval { my $result = ( 23 / $z ) }
|| MyException->throw( error => 'I feel funny.' )
};
# my $e;
# catch
if( my $e = Exception::Class->caught( 'MyException' ) ) {
warn $e->error, "\n", $e->trace->as_string, "\n";
warn join ' ', $e->euid, $e->egid, $e->uid, $e->gid, $e->pid, $e->ti
+me;
exit;
} else {
$e = Exception::Class->caught();
ref $e ? $e->rethrow : die $e;
}
__END__
I feel funny.
Trace begun at index.pl line 9
eval {...} at index.pl line 8
1000 1000 1000 121 120 117 115 109 108 106 104 46 44 30 29 25 24 20 6
+4 0 1000 1000 1000 121 120 117 115 109 108 106 104 46 44 30 29 25 24
+20 6 4 0 10107 1221493762 at index.pl line 17.
[]s, HTH, Massa (κς,πμ,πλ)
|