Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

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

by jmcnamara (Monsignor)
on Oct 23, 2001 at 15:46 UTC ( #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 fire pops...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2018-06-25 01:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (126 votes). Check out past polls.

    Notices?