Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Answer: What is the simplest way to print a field, as in $3 does in awk

( #120753=categorized answer: print w/ replies, xml ) Need Help??

Q&A > strings > What is the simplest way to print a field, as in $3 does in awk - Answer contributed by jmcnamara

Use the -a switch to autosplit to @F.
perl -lane 'print if $F[1] =~ /localhost/' /etc/hosts
or     perl -lne 'print if /localhost/' /etc/hosts
--
John.

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2016-07-29 17:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What is your favorite alternate name for a (specific) keyboard key?


















    Results (264 votes). Check out past polls.