Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: a one-liner for this trivial problem?

by NetWallah (Abbot)
on Apr 16, 2013 at 23:35 UTC ( #1029027=note: print w/replies, xml ) Need Help??

in reply to a one-liner for this trivial problem?

How about this:
perl -ne "$small||=$ARGV; $small eq $ARGV? $h{$_}++: $h{$_}?0:print" s +mall.txt large.txt
This takes advantage of the fact that $ARGV contains the file name.

Use single-quotes if you run in *nix.

             "I'm fairly sure if they took porn off the Internet, there'd only be one website left, and it'd be called 'Bring Back the Porn!'"
        -- Dr. Cox, Scrubs

Replies are listed 'Best First'.
Re^2: a one-liner for this trivial problem?
by space_monk (Chaplain) on Apr 17, 2013 at 04:22 UTC

    Good idea, but removing the hard coding of file names perhaps gives....

    perl -ne " $ARGV eq $ARGV[0] ? $h{$_}++ : $h{$_} ? 0 : print; " small.txt large.txt
    A Monk aims to give answers to those who have none, and to learn from those who know more.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1029027]
[LanX]: ha the Cuban experience
[LanX]: one strange thing I heard was that pharmacies in Vietnam are run by Russians
[LanX]: still can't believe this, must h have been a misunderstanding
[choroba]: fortunately, I haven't the need to verify this
[choroba]: haven't had

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2017-02-26 04:55 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (371 votes). Check out past polls.