Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
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 studying the Monastery: (5)
As of 2014-11-27 19:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (187 votes), past polls