I've been staring at this (originally one line) segment of code, and I cannot figure out what is going wrong, exactly. I have a snippet of code here (for external reference, $digest and $entry are simple scalars containing strings, not that they're used strangely here) that I have broken down into as many steps as I could to pinpoint what was going wrong, inserting print statements along the way (to no avail), the code also runs with strict and warnings on:
my %hash = ('digest'=>$digest, 'entry'=>$entry); my $hashref = \%hash; print ref $hashref, "|"; push @out, $hashref; print ref $out[$#out], "|$out[$#out]";
This prints: HASH||HASH(0x3e00258). The first ref() call suggests that $hashref is a valid hash reference, the second call returns false, and the third segment prints out a string representation of a hash reference. This suggests to me that since the second ref() call fails, yet $out[$#out] contains the string representation of a hash ref, that the last element in @out is a stringified version of a valid hash ref.
At this point, my brain taps me on the shoulder and says quite matter-of-factly that push() does not do anything to the list portion of its parameters, and that's the only operation performed on it between tests. This is verified by testing a smaller script containing just this code.

So I suppose my question is really: what could I possibly be doing outside of this code to get this outcome? The only variables not initialized in this snippet are two strings only used in the assignment of the hash, and an array which is only used to retrieve the last item, which was pushed onto it in the scope of this snippet.

In reply to Pushed references getting stringified somehow? by charnos

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.