use Exception::Class ( 'X::FatalIOError' => { # fields etc. }, 'X::TimeOut' => { } ); eval { somecode() }; if ( X::FatalIOError->caught()) { # do something and die } elsif (X::TimeOut->caught() ) { # wait and retry } elsif (Exception::Class->caught() ) { # got an exception we weren't expecting # die horribly or something }