Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Stack table columns with hash of arrays

by Marshall (Canon)
on May 31, 2011 at 09:49 UTC ( [id://907431]=note: print w/replies, xml ) Need Help??


in reply to Stack table columns with hash of arrays

Another solution for you.
#!/usr/bin/perl -w use strict; my @RowNames; my @Columns; while (<DATA>) { my $i=0; my ($name, @row)= split; push @RowNames, $name; push @{$Columns[$i++]}, $_ for (@row); } foreach my $cref (@Columns) { foreach my $name (@RowNames) { print "$name\t",shift @$cref,"\n"; } } =prints foo1 1 foo2 2 foo3 3 foo1 4 foo2 5 foo3 6 foo1 7 foo2 8 foo3 9 =cut __DATA__ foo1 1 4 7 foo2 2 5 8 foo3 3 6 9

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-04-26 00:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found