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.