#!/usr/local/bin/perl -w use strict; sub xget { my $hash = shift; return map $_->{'value'}, @$hash{@_}; } my $hash = { foo => { value => "FOO" }, bar => { value => "BAR" }, }; print "$_\n" for xget($hash, qw(foo bar) );