Hello.. I have a bit of an odd problem (I think its odd. It might not be). I've written a module that exports a single function. This function opens a file, reads in each line, and builds an assocative array based on whats coming in setup by doing my %data = { };. A simple unpack into an array and then $data{@field[0]}{@array[0]} = @array1; $data{@field1}{@array[0]} = @array2; and so on. Thus array[0] is like a primary key etc. The module returns this as a reference using return \%data;

I then do, for example, $records = newfile("text.txt"); to set up the associative array reference, $records is a reference to %data. Then I did @primary = keys(%{$records});. I didn't get quite what I expected.

I was hoping for an array holding all the values that had come from @array[0]. I got them. However, I also got something that looked like 0hashX0f, a hash reference I think, in the first element of the @primary array. Other attempts at fixing it moved the hash reference (?) to other places in the array, seemingly randomly.

Unfortunately the code is at home. Else I'd post it.

Help? Chris $live{$free}||die

In reply to Odd hash problem. by onion2k

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.