#untested, no perl on the current machine... my @array= qw ( command1 command2 command3); my %hash = (); foreach (@array) { $output = eval($_); $hash->{$_}= $output; } sub command1() { # do something return 1; }