Printing an array of hash refs

From: Tony N. (tnitzke_at_simpson.com)
Date: 09/22/04


Date: 22 Sep 2004 08:35:33 -0700

I'm using the following code to print an array of hash refs. It seems
to me there should be a more concise way to do this. I don't like the
trailing \t or the extra line of code to get the \n. Any pointers
would be appreciated.

print "$_\t" for sort keys %{$rows[0]};
print "\n";

for my $row (@rows) {
        print "$row->{$_}\t" for sort keys %{$row};
        print "\n";

}



Relevant Pages

  • Re: Printing an array of hash refs
    ... Tony N. wrote: ... > I'm using the following code to print an array of hash refs. ... > to me there should be a more concise way to do this. ...
    (comp.lang.perl.misc)
  • Re: Printing an array of hash refs
    ... tnitzke@simpson.com (Tony N.) wrote: ... I'm using the following code to print an array of hash refs. ... Any pointers ...
    (comp.lang.perl.misc)
  • Re: Printing an array of hash refs
    ... Tony N. wrote: ... > I'm using the following code to print an array of hash refs. ... > to me there should be a more concise way to do this. ...
    (comp.lang.perl.misc)
  • Re: Printing an array of hash refs
    ... Paul Lalli wrote: ... >>I'm using the following code to print an array of hash refs. ... >>to me there should be a more concise way to do this. ...
    (comp.lang.perl.misc)
  • RE: fetchall_hashref error: invalid number of parameters?
    ... Hey Rob - ... contained in an array ref), so I have to dereference and iterate the array ... ref to get to the hash refs underneath. ... so you can't dereference it as an array. ...
    (perl.beginners)