Welcome to the Monastery | |
PerlMonks |
Smart way to read a file vertically?by Anonymous Monk |
on Jun 05, 2012 at 21:10 UTC ( [id://974564]=perlquestion: print w/replies, xml ) | Need Help?? |
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks! I am looking to see if there could be a clever way to read a tab-separated file (copied from an excel sheet) vertically. Image that you have: and you want to print out firstly the list of names, then the list of last names, the list of phones and the list of emails. My approach (maybe a stupid one) would be to read the first line, split it using "\t" as delimeter, and then, while reading each line, splitting them as well and appending, for example, the preffix NAME to each element of each line that appears in the [0] position of the temporary array that will be created. Can you show me another, more efficient way for this?
Back to
Seekers of Perl Wisdom
|
|