Re: Printing an array of hash refs
From: Jay Tilton (tiltonj_at_erols.com)
Date: 09/23/04
- Next message: Eric Schwartz: "Re: new commands written in perl"
- Previous message: Andres Monroy-Hernandez: "Re: Modulus Operator (%)"
- In reply to: Tony N.: "Printing an array of hash refs"
- Next in thread: Tony N.: "Re: Printing an array of hash refs"
- Reply: Tony N.: "Re: Printing an array of hash refs"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 23 Sep 2004 00:02:12 GMT
tnitzke@simpson.com (Tony N.) wrote:
: 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";
: }
{
local($, , $\) = ("\t", "\n");
print sort keys %{$rows[0]};
print @$_{sort keys %$_} for @rows;
}
- Next message: Eric Schwartz: "Re: new commands written in perl"
- Previous message: Andres Monroy-Hernandez: "Re: Modulus Operator (%)"
- In reply to: Tony N.: "Printing an array of hash refs"
- Next in thread: Tony N.: "Re: Printing an array of hash refs"
- Reply: Tony N.: "Re: Printing an array of hash refs"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|