in reply to comparing an ID fom one file to the records in the second file
Store the ID's as hash keys and use exists to match records in the data file
poj#!/usr/bin/perl use strict; use Data::Dumper; my %ID = (); my $fileID = 'BreastCnAPmiRNAsID.txt'; open FILEID, '<', $fileID or die "cannot open $fileID"; while (<FILEID>){ chomp; $ID{$_}=1 if $_; } close FILEID; #print Dumper \%ID; my $fileCompare = 'tarbaseData.txt'; open FILECOMPARE, '<', $fileCompare or die "cannot open $fileCompare"; while(<FILECOMPARE>){ chomp; my @col = split "\t",$_; print "$col[2]\n"; if (exists $ID{$col[2]}){ print $_; } } close FILECOMPARE;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: comparing an ID fom one file to the records in the second file
by ag88 (Novice) on Dec 02, 2017 at 11:27 UTC | |
by poj (Abbot) on Dec 02, 2017 at 11:45 UTC | |
by ag88 (Novice) on Dec 02, 2017 at 12:33 UTC |