Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Column wise entry in text table

by Cristoforo (Deacon)
on Jan 20, 2013 at 18:18 UTC ( #1014315=note: print w/ replies, xml ) Need Help??


in reply to Column wise entry in text table

The code you provided is just the sample code for Text::Table. What have you tried?

You will need to transpose the table before you submit it to Text::Table. Something like this: my @transpose = transpose(@matrix); where @matrix is your array to transpose.

sub transpose { my @array = @_; my $max_j = max map $#$_, @array; my @trans; for my $i (0 .. $#array) { for my $j (0 .. $max_j) { $trans[$j][$i] = $array[$i][$j]; } } return @trans; }
This requires the function 'max' from List::Util.

Update: The transpose function above will not enter '0' in the array if it is in the data. It should be correct now.

I'm not sure whether it is right to set a max_j as it is so, here it is without that detail.

sub transpose { my @array = @_; my @trans; for my $i (0 .. $#array) { for my $j (0 .. $#{$array[$i]}) { $trans[$j][$i] = $array[$i][$j]; } } return @trans; }


Comment on Re: Column wise entry in text table
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (17)
As of 2014-07-28 18:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (205 votes), past polls