Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: Odd

by wog (Curate)
on Feb 23, 2002 at 01:51 UTC ( #147019=note: print w/replies, xml ) Need Help??

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.)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://147019]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2017-02-27 23:14 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (393 votes). Check out past polls.