eval { #line 1 "AI::Prolog primitive: perlcall2/2" ... }; #line ??? "Primitive.pm" if ( my $e = $@ ) { if ( $e =~ m{at AI::Prolog primitive: perlcall2/2} ) { Got it! } elsif ... }