eval { do_something_that_could_die() }; if($@) { # We know it died, but is it an object or a # printable message? if( ref $@ ) { # Assume it's an exception object. Not a # great way to do it, but it works. # # Now, what kind of exception is it? # if( $@->isa( 'IOException' ) ) { . . . } elsif( $@->isa( 'OtherException' ) ) { . . . } else { . . . } } else { # Assume it's an error string . . . } }