##
#! perl
use strict;
use warnings;
my %names;
while ()
{
my ($first, $last) = split;
push @{$names{$first}}, $last if $last;
}
my $name_to_find = 'John';
print "$name_to_find --> ", join(', ', @{$names{$name_to_find}}), "\n";
__DATA__
John Marry
John Lea
John Paul
David Patrik
David Sam
####
16:53 >perl 545_SoPW.pl
John --> Marry, Lea, Paul
16:56 >