Re: Printing an array of hash refs
From: Mark Clements (mark.clements_at_kcl.ac.uk)
Date: 09/22/04
- Next message: LHradowy: "Re: Perl script to clean up file -- Dont know if it can be done"
- Previous message: Eric Schwartz: "Re: new commands written in perl"
- In reply to: Tony N.: "Printing an array of hash refs"
- Next in thread: John W. Krahn: "Re: Printing an array of hash refs"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 22 Sep 2004 19:05:57 +0200
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";
>
> }
check out Data::Dumper.
Mark
- Next message: LHradowy: "Re: Perl script to clean up file -- Dont know if it can be done"
- Previous message: Eric Schwartz: "Re: new commands written in perl"
- In reply to: Tony N.: "Printing an array of hash refs"
- Next in thread: John W. Krahn: "Re: Printing an array of hash refs"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|