Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
while (<>) {
chomp;
@ary = split;
$user = shift @ary;
$cluster{$user} = \@ary;
undef @ary;
}
foreach $user ( sort ( keys ( %cluster ))) {
print "$user $cluster{$user} @{$cluster{$user}}\n";
}
I expect to see output like
username ARRAY(0x8101b94) username's_friend
but I don't get username's_friend at all, and the ARRAY pointer I get is always the same, and alway the array that points to the last line of input. -clay
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(Ovid) Re: Arrary ref stored in hash always points to the same array?
by Ovid (Cardinal) on Mar 01, 2002 at 17:47 UTC | |
|
Re: Arrary ref stored in hash always points to the same array?
by VSarkiss (Monsignor) on Mar 01, 2002 at 17:47 UTC | |
|
•Re: Arrary ref stored in hash always points to the same array?
by merlyn (Sage) on Mar 01, 2002 at 23:48 UTC |