Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Accessing this array ref.

by Loops (Curate)
on Apr 03, 2013 at 18:58 UTC ( [id://1026892]=note: print w/replies, xml ) Need Help??


in reply to Accessing this array ref.

You want to loop through the array, printing each item. Since the array is already sorted into groups, you just print a new group header when the value changes:

use feature 'say'; my $type; for my $entry (@$VAR1) { if ( $entry->{type} ne $type ) { $type = $entry->{type}; say $type; } say "\t$entry->{name} - $entry->{reference}"; }

Replies are listed 'Best First'.
Re^2: Accessing this array ref.
by Anonymous Monk on Apr 03, 2013 at 19:23 UTC
    This would do it, I could combined all the data into one variable and print at once instead of printing them in the IF, right?
      I don't understand your question. If the data is sorted as Loops said, his solution should work for you.
        I am sorry, is that at the end of processing I have to pass the values as this:
        $template->param('data', $results);

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1026892]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-25 13:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found