in reply to Hashes/Scalars and Memory Usage

AgentM was just blowing gas here. Never mind.

Thanks to Fastolfe, chipmunk, myocom for the explanations and for catching my mistake.

AgentM Systems nor Nasca Enterprises nor Bone::Easy nor Macperl is responsible for the comments made by AgentM. Remember, you can build any logical system with NOR.

Replies are listed 'Best First'.
Re: Re: Hashes/Scalars and Memory Usage
by Fastolfe (Vicar) on Feb 09, 2001 at 00:32 UTC
    use Data::Dumper; foreach (qw/ one two three /) { $hash{$_} = "in hash: $_"; $array[$_] = "in array: $_"; } print Dumper(\%hash, \@array); $VAR1 = { 'one' => 'in hash: one', 'three' => 'in hash: three', 'two' => 'in hash: two' }; $VAR2 = [ 'in array: three' ];
    The string in the array assignment is being interpreted in a numeric context, which makes it 0. Thus you are getting data from and assigning to index 0 of the array every time. The hash will grow, while the array will only contain the last item you save.