while() { chomp; ($sp, $ipr) = split; if (exists $p2i{$sp}) { push @{$p2i{$sp}}, $ipr; # push @{$p2i{sp}}, $ipr; } else { $p2i{$sp}= [$ipr]; } } close FILE; # test to see if hash created correctly foreach $key (sort keys %p2i) { # print "$key\t$p2i{$key}\n"; print "$key\t@{$p2i{$key}}\n"; } if (exists $p2i{$user}) { # print "$user is in the hash. \n";if (exists $p2i{$user}) { print "$user is in the hash. \n"; # @user_array = split(/ /, $p2i{$user}); # @user_array = split(/ /, $p2i{$user}); # foreach (@user_array) { # print "$_\n"; # } foreach (@{$p2i{$user}}){ print "$_ "; } print "\n"; # print "$user: @{ $p2i{$user} }\n"; # only retieves one value even when more than one #val even if there are multiple # } } else { print "$user is not in the hash.\n"; } exit;