use strict; use warnings; use diagnostics; my $m = bless{}, "main"; eval{ $m->foo }; if ($@) { say "perl $]: $@" }