Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: Pattern matching across two files, Need something better than grep -f!

by Anonymous Monk
on Apr 10, 2012 at 18:52 UTC ( #964388=note: print w/ replies, xml ) Need Help??


in reply to Re: Pattern matching across two files, Need something better than grep -f!
in thread Pattern matching across two files, Need something better than grep -f!

A little bit faster:
use strict; use warnings; open my $data_fh, '<', "data" or die $!; open my $patern_fh, '<', "pattern.txt" or die $!; my %patterns; while (<$patern_fh>) { $patterns{join $;, split} = (); } close $patern_fh; { local $, = "\t"; local $\ = "\n"; while (<$data_fh>) { my @line = split; if (exists $patterns{$line[0] . $; . $line[1]}) { print @line[0, 1, 3]; } } } close $data_fh;
  • Comment on Re^2: Pattern matching across two files, Need something better than grep -f!
  • Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2016-06-27 10:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (337 votes). Check out past polls.