Try
poj#!perl use strict; my @array = qw( -- 0.0175 0.0483 0.0507 -- 0.0471 0.0483 -- 0.0287 --); my @column; my $curr_column = 0; my $rows = 0; while (@array) { if( $array[0] ne '--' ) { push @{ $column[ $curr_column ] }, shift @array; if( $rows < $#{ $column[ $curr_column ] } ) { $rows = $#{ $column[ $curr_column ] }; }; } else { $curr_column++; $column[ $curr_column] ||= [0]; # a new column shift @array; }; }; for my $row (0..$rows) { my @tmp = (); for (@column){ if ( exists ($_->[ $row - $rows -1 ]) ){ push @tmp,$_->[ $row - $rows - 1 ]; } } print join "\t", @tmp; print "\n"; };
In reply to Re^7: array in different columns
by poj
in thread array in different columns
by Muflone82
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |