eval { use autodie; open( my $fh, '<', $my_file ); # ... close($fh); }; if ( $@ and $@->isa('autodie::exception') ) { if ( $@->matches('open') ) { print "Error from open\n"; # ... } } else { # open OK... }