Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Smart way to read a file vertically?

by snape (Pilgrim)
on Jun 05, 2012 at 21:22 UTC ( [id://974570]=note: print w/replies, xml ) Need Help??


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!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-18 04:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found