Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: find common data in multiple files

by BrowserUk (Pope)
on Dec 28, 2017 at 10:56 UTC ( #1206317=note: print w/replies, xml ) Need Help??


in reply to find common data in multiple files

If you do:

my %hash; ++$hash{ $_ } while <>;

It will add and increment an entry in the hash for each line of every file named on the command line.

Then all you need to do is run through the hash and print out any key with a value equal to the number of files:

$hash{ $_ } == @ARGV and print for keys %hash;

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
In the absence of evidence, opinion is indistinguishable from prejudice. Suck that fhit

Replies are listed 'Best First'.
Re^2: find common data in multiple files
by Laurent_R (Canon) on Dec 28, 2017 at 11:18 UTC
    Yes, I was thinking about a similar solution. Short, easy, and efficient. Please note, however, that this will work properly only provided there are are no duplicate entries in the individual input files.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1206317]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2018-07-23 02:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (459 votes). Check out past polls.

    Notices?