Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: extract line

by Loops (Curate)
on Jul 20, 2013 at 18:38 UTC ( [id://1045460]=note: print w/replies, xml ) Need Help??


in reply to extract line

Probably there is a shorter one liner than this:

perl -F: -ane 'BEGIN {open K, "<file2"; $h{0+$_}=1 for <K>} print if e +xists $h{$F[0]}' file1

Replies are listed 'Best First'.
Re^2: extract line
by rjt (Curate) on Jul 20, 2013 at 20:56 UTC

    How about this?

    perl -pe'open _,file2;0+$_~~[<_>]or$_=""' file1

    47 chars, versus 91 (84, removing unnecessary whitespace). This one's definitely "just for fun", though, due to now-experimental smartmatch and re-reading of file2.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-04-23 09:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found