package Exception; use strict; our ($try, $catch, $prior_catch); BEGIN { use Exporter; our ($VERSION, @ISA, @EXPORT); $VERSION = "0.04.5"; @ISA = qw(Exporter); @EXPORT = qw(&try &catch); *CORE::GLOBAL::die = \¨ # this really should probably be done another # way or at least be optional. } sub die { my $catch_sub = $catch; local $catch = $prior_catch; local $_ = shift; chomp; (defined($catch_sub) && $catch_sub ne "" && &$catch_sub) || CORE::die $_; } sub catch (&) { } sub try (&@) { local $prior_catch = $catch; { local ($try, $catch) = @_; eval { &$try; } } &die($@) if $@; } return 1;