my %people = ( 7 => { name => 'Bob Jones', address => '555 Anywhere Street', city => 'Allentown', state => 'Pennsylvania' }, 3 => { name => 'Pete Hollister', address => '222 Northview Drive', city => 'Shoreham', state => 'unknown' }, 9 => { name => 'Pete Hollister', address => '222 Northview Drive', city => 'New York', state => 'unknown' } ); my $name = 'Pete Hollister'; my @cities = map { $people{ $_ }{ name } eq $name ? $people{ $_ }{ city } : () } keys %people; $,=', '; # This sets the array separator to a comma and space, allowing # easy printing of arrays print @cities;