eval { foo() or die "foo failed"; bar() or die "bar bombed"; baz() or die "baz blew chunks"; # etc. }; # don't forget that semicolon! handle_error($@) if $@; # life is good... # ...and in some dark corner of your code sub handle_error { my $msg = shift; if ( $msg =~ /foo/ ) { # deal with foo's error; } elsif ($msg =~ /bar/ ) { # deal with bar's error } # etc. else { # deal with unexpected error } }