use POSIX qw( :errno_h ); ## Something that fails here if( $! == EISDIR ) { warn "error was directory\n" }