in reply to Pattern matching across two files, Need something better than grep -f!
Try Hash table for comparing the two files.
#!usr/bin/perl use strict; use warnings; my %data1; ## Hash for Pattern File open IN1, 'patterns.txt' or die $!; while (<IN1>){ chomp $_; my @line = split('\t',$_); $data1{$line[0]} = $line[1]; } close (IN1); open IN2, 'data.txt' or die $!; while( <IN2> ) { my @line = split('\t',$_); if (exists $data1{$line[0]}){ print$line[0],"\t", $line[1],"\t",$line[2],"\t",$line[3], "\n"; } } close IN2;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Pattern matching across two files, Need something better than grep -f!
by Anonymous Monk on Feb 18, 2013 at 13:13 UTC | |
by Anonymous Monk on Feb 21, 2013 at 04:58 UTC |