Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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


In reply to Re: Odd by wog
in thread Odd: Out of memory! error by BlueLines

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-16 20:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found