$ perl -le 'sub a { "x" } sub b { "y" }; $p = bless {}; for $key ( qw( a b ) ) { print $p->$key() }' x y