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

Re: Accessing Tab Delimited Field in Perl One-Liner

by aufflick (Deacon)
on Jun 01, 2009 at 01:32 UTC ( [id://767155]=note: print w/replies, xml ) Need Help??


in reply to Accessing Tab Delimited Field in Perl One-Liner

There is for sure going to be a shorter more golf-ish solution, but the obvious one is:

perl -ne '@cols = split /\t/; print if $cols[1] == 0' mydat.txt
  • -n means iterate the next block of code over the supplied files one line at a time (where line means whatever is separated by the value of $/ which is the newline of your platform by default). The text line is presented in the variable $_ with a newline.
  • -e means interpret the next commandline argument as a chunk of code.
  • Many builtins, such as split, print and // regex matching, operate on $_ by default if no string/list argument is given.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2024-04-18 15:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found