Try pushing the values onto your array:

my @data; foreach $head (keys %hoa) { push @data, $hoa{$head}; $item = shift(@data); print OUTFILE "$item"; print OUTFILE ","; }

For your specific example, this would work just as well:

print OUTFILE join ',' values %hoa;
If you really want to do what you're trying to show (creating an array with one item and then removing that item), you would have to:
foreach $head (keys %hoa) { my @data = ( $hoa{$head} ); $item = shift(@data); print OUTFILE "$item"; print OUTFILE ","; }

Update: I just realized what you were trying to do :) I'm assuming %hoa is actually a hash of arrayrefs, right? I'm guessing that something is actually going on with the construction of your HoA such that your hash entries are actually pointing at undef instead of the arrayrefs you are expecting. Try using Data::Dumper to dump out %hoa before you try to access its content. Can you post the code that you are using to build %hoa?

perl -e 'split//,q{john hurl, pest caretaker}and(map{print @_[$_]}(joi +n(q{},map{sprintf(qq{%010u},$_)}(2**2*307*4993,5*101*641*5261,7*59*79 +*36997,13*17*71*45131,3**2*67*89*167*181))=~/\d{2}/g));'

In reply to Re: Hash of arrays.. can't shift on derefferenced array by agianni
in thread Hash of arrays.. can't shift on derefferenced array by esddew

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.