Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^3: File Reading

by Skeeve (Parson)
on Oct 05, 2007 at 08:15 UTC ( [id://642847]=note: print w/replies, xml ) Need Help??


in reply to Re^2: File Reading
in thread File Reading

So now as he was unseccessfull, I'd like to get the job ;-)

Here is my solution, lacking any kind of error checking of course...

#!/usr/bin/perl use strict; use warnings; # read headline $_= <DATA>; chomp; # split into words my @headline= split /:/; # assign each word a column number my %headline; @headline{@headline}= (0..$#headline); # get the required columns my @columns= @headline{@ARGV}; # print the column headers print join(':',@ARGV),"\n"; # read each line while (<DATA>) { chomp; # and print what's requested print join(':',(split /:/)[@columns]),"\n"; } __DATA__ AGE:EYES:HAIR 32:BLUE:BLONDE 54:BROWN:BROWN

s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
+.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-04-24 17:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found