in reply to de-ref an array from HoA

I found 4 problems with your code:
2 syntax errors
1 logical error
1 formatting for this site error

syntax error #1:
you have
push @{$p2i{sp}}, $ipr; # $ missing for key reference
when you should have
push @{$p2i{$sp}}, $ipr;

syntax error #2:
you have
print "$key\t$p2i{$key}\n";
when you should have
print "$key\t@ {$p2i{$key} }\n"; # need @ to dereference array

logical error #1:
your use of uc() for key lookups will return nothing because the hash keys, as entered from the text file, are all lowercase (at least in the sample you provided).

formatting error #1:
you have
if (exists $p2i{$user}) { print "$user is in the hash. \n";if (exists $p2i{$user}) { print "$user is in the hash. \n";
when you should have
if (exists $p2i{$user}) { print "$user is in the hash. \n";


I corrected the above and the code ran fine

hope this helps,
davidj

Replies are listed 'Best First'.
Re^2: de-ref an array from HoA
by stalkeyefly (Novice) on Jun 17, 2004 at 14:37 UTC
    Thanks to you all the code works now!

    Cheers
    Stalky