in reply to Re^5: array in different columns
in thread array in different columns
so I addedGlobal symbol "$index" requires explicit package name at /home/../scri +pts/creaNexusMatrix.pl line 12. Execution of /home/../scripts/creaNexusMatrix.pl aborted due to compil +ation errors.
and the code began;my $index;
Now the script works but I didn't obtain that I hope... I obtained:my @column; my $index; my $curr_column = 0; my $rows = 0; while( @array) { if( $array[0] ne '--' ) { $column[ $curr_column ] ||= []; # a new column push @{ $column[ $curr_column ] }, shift @array; if( $rows < $#{ $column[ $curr_column ] } ) { $rows = $#{ $column[ $curr_column ] }; }; } else { $index++; shift @array; }; }; for my $row (0..$rows) { print join "\t", map { $_->[ $row ] } @column; print "\n"; };
-- 0.0175 0.0483 0.0507 -- 0.0471 0.0483 -- 0.0287 --
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: array in different columns
by poj (Abbot) on Nov 23, 2016 at 13:36 UTC | |
by Muflone82 (Novice) on Nov 23, 2016 at 13:52 UTC | |
by Marshall (Canon) on Nov 24, 2016 at 09:04 UTC |