use English '-no_match_vars'; my $ref = 'this'; my $x = eval "&$ref()"; if ( my $error_message = $EVAL_ERROR ) { if ( $error_message =~ /^Undefined subroutine / ) { # a dispatch table would have caught this } }