What you have is an array of arrays of hashes. You can not strip off the outer array, or else you'd be trying to stuff a bunch of array refs into a single scalar, and that won't fly.

What I think you want to do is simply iterate over the encompassing array and act on each inner aref one at a time:

my @numbers = collect(@test); sub collect { my @test = @_; my @all; for my $more_rec (@test){ for my $number (keys %{ $more_rec }){ my $numbers = $more_rec->{$number}; push @all, $numbers->{agenda}; } } return @all; }

However, it's doubly difficult to really understand what you want, because your data examples do not jive with what was in your collect() function. In there, you're extracting an href ($numbers) from within another href ($more_rec), and then from within $numbers, you're extracting the value of the agenda key. None of that is shown in your example data. Also, your collect() has at least one issue. You extract $number from keys(), but then never proceed to use it.


In reply to Re: Remove one level from array by stevieb
in thread Remove one level from array by Anonymous Monk

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.