On Nov 4, Brian Ling said:
>If I, push @save_array, \%hash_data I obviously get a array referencing
>the same mem address for each loop, the value of which gets overwritten
>next time round.
Then you need to scope your hash. When you declare the hash, use my:
for (...) {
my %hash = something();
push @saved, \%hash;
}
or, use the anonymous hash constructor to COPY the contents of the hash:
for (...) {
%hash = something();
push @saved, { %hash };
}
But I prefer the first method.
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
[ I'm looking for programming work. If you like my work, let me know. ]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]