Are you sure about that? Unlike C, perl can do sparse arrays without using lots of memory for the empty slots, so you can write:
my @test = (); $test[ 0 ] = 'first'; $test[ 10_000_000 ] = 'last';
If the array index was used to directly calculate the RAM location of the data, then perl would have to allocate lots of it for the table. The fact that the code above works suggests that perl keeps a lookup table somewhere of valid values. That lookup table will be similar to the one needed for a hash, and potentially no faster.
In reply to Re^2: Array or Hash
by chrestomanci
in thread Array or Hash
by palanisamy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |