Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: File Reading

by aquarium (Curate)
on Oct 01, 2007 at 15:20 UTC ( [id://641921]=note: print w/replies, xml ) Need Help??


in reply to File Reading

excuse the political incorrectness.....is this the entrance question for a job as a perl programmer in an indian call centre?....because then the output should actually be
32:blue:blonde --> gullible target?
54:brown:brown --> not a threat to the blonde
only kidding folks
i think homework should receive obfuscated code...if any, as no attempt was made
the hardest line to type correctly is: stty erase ^H

Replies are listed 'Best First'.
Re^2: File Reading
by Anonymous Monk on Oct 02, 2007 at 12:58 UTC
    aquarium was closest. mantra2006 was trying to get a job.

    he was unsuccessful.

      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://641921]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-26 06:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found