#!/usr/bin/perl -w # perl.ID.match.pl use strict; use warnings; open(KEY, ") { chomp $key; @Key=split("\t",$key); $Chr{$Key[0]} = undef; } open(FULL, "chr1.match.txt") or die "error reading file"; while (my $line=) { chomp $line; @line=split("\t",$line); foreach my $key (sort keys %Chr) { if ($line[0] eq $key) { print OUT "$line\n"; } } } close KEY; close FULL; close OUT; exit;