http://qs321.pair.com?node_id=147019


in reply to Odd: Out of memory! error

Your code uses something called pseudo-hashes. Quoth perlref (bleedperl):

[stuff about this being an experimental feature, and the user-visible implementation of pseudohashes begin deprecated in perl 5.8 and slated to go away in perl 5.10.]

Beginning with release 5.005 of Perl, you may use an array reference in some contexts that would normally require a hash reference. This allows you to access array elements using symbolic names, as if they were fields in a struc ture.

For this to work, the array must contain extra informa tion. The first element of the array has to be a hash reference that maps field names to array indices. Here is an example:

$struct = [{foo => 1, bar => 2}, "FOO", "BAR"];
[more code snipped]

You've declared a pseudohash with one element, "c", which is located at the location that {} turns into when it is used as a number. {} is a reference, and when used as a number turns into it's memory location (so it can be compared, mainly). It's memory location is likely to be a very high number. When you access $record->{c}, perl tries to access the array element in @$record at the index specified by that memory location. Since that array element doesn't exist perl tries to expand the array, and fails saying it doesn't have enough memory. (Since arrays can't be stored with holes in perl.)