eval { &$sub }; if ( $@ =~ /^Undefined subroutine/ ) { # This is what happens when you call a bogus sub ref. } elsif ( $@ ) { die $@; }