use strict; use warnings; my $obj = bless {}; my @mem = qw(hello world); for (@mem) { my $mem = "_do_$_"; next unless $obj->can ($mem); $obj->$mem (); } sub _do_hello {print 'hello ';} sub _do_world {print "world\n";} sub _do_nothing {print 'nothing ';}