package Foo; my %attrs = map { $_ => 1 } qw/ this that /; AUTOLOAD { my ($m) = our $AUTOLOAD =~ /.*::(.*)/s; return if $m eq 'DESTROY'; if ($attrs{$m}) { print "OK: $m"; } else { print "Failure: $m"; # Here you need to emulate perl error message. # Note that you don't want to use the Carp # module for this. } }