in reply to Sort multi-dimensional array based on dereferenced value - out of memory error
When you use a reference as a number, it evaluates to the memory address of the referencee. This address can be a rather large number, and your code autovivifies an array big enough to hold that many elements.
$ perl -wE 'say 0 + []' 10034664
So it tries to create an array with about 10Mio elements on my machine.
The fix is to use just $a in place of $aref->[$a] in your code
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Sort multi-dimensional array based on dereferenced value - out of memory error
by lbmp (Initiate) on Sep 05, 2011 at 15:32 UTC |