use strict; use warnings; my @methodcalls = qw (getExeName getTempName); my @getDataMethods = qw (getNameType); my $obj = Foo->new(); my %hash; my $counter=0; for my $call (@methodcalls) { $hash{"temp".$counter} = $obj->$call; $counter++; } for my $call (@getDataMethods) { $hash{"temp".$counter} = $obj->getData->$call; $counter++; } for (keys %hash) { print "$_\t $hash{$_}\n"; } package Foo; sub new { return bless \{}, shift; } sub getExeName { return "exename"; } sub getTempName { return "tempname"; } sub getData { return shift; } sub getNameType { return "nametype"; } #### use strict; use warnings; my $obj = Foo->new(); my %hash; my $counter=0; my @methodcalls = qw (getExeName getTempName getData->getNameType); for my $call (@methodcalls) { my $evalstring = "\$obj->$call"; $hash{"temp".$counter} = eval($evalstring); $counter++; } for (keys %hash) { print "$_\t $hash{$_}\n"; }