in reply to Smart way to read a file vertically?

Your method is perfect if you are interested in reading particular column or columns of the file. Also, genrally in all programming languages we read the file row by row and not column by column

I can suggest a lame method but that is way to complex. If you are interested in reading the file vertically taking account of all the columns then you could transpose the file and then read it. Something like this:

for my $row (@rows) { for my $column (0 .. $#{$row}) { push(@{$transposed[$column]}, $row->[$column]); } } for my $new_row (@transposed) { for my $new_col (@{$new_row}) { print $new_col, " "; } print "\n"; }

Again it is a lame method.

Replies are listed 'Best First'.
Re^2: Smart way to read a file vertically?
by Anonymous Monk on Jun 05, 2012 at 21:25 UTC
    Thanks guys to all of you that put an effort into helping me... I think I'll try out the 2 snipets of code, but also check out the modules as suggested!
    Thanks for always being here to help the newbies!