Re: Printing an array of hash refs

From: Paul Lalli (mritty_at_gmail.com)
Date: 09/22/04


Date: Wed, 22 Sep 2004 15:49:15 GMT


"Tony N." <tnitzke@simpson.com> wrote in message
news:638483db.0409220735.49486c78@posting.google.com...
> 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.
> for my $row (@rows) {
> print "$row->{$_}\t" for sort keys %{$row};
> print "\n";
> }

for my $row (@rows){
    print (join ("\t", sort keys %$row), "\n");
}

Paul Lalli



Relevant Pages

  • 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
    ... 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: Opinions? Is it _GOOD_ that foreach() throws warning when given undef var?
    ... nothing to put in it then it should return an empty array, ... Likewise if any PHP function expects an array and you give it something else ... Tony Marston ... > "Tony Marston" wrote in message ...
    (comp.lang.php)