#!/usr/bin/perl use strict; my $f = "vc_20151003_1.zip"; my $cat = "5426085.csv"; my $file = $f; my $file =~ s/.zip/.csv/; ## Read the cat file into hash %catHash = (); open(CAT, $cat) || die "$cat couldn't be opened\n"; while() { @line = split /,/; $catHash{$line[1]}++; } close(CAT); open(OUT, ">".$file) || "$file couln't be opened for write\n"; open(IN,sprintf("zcat %s |", $f)) || die "Could not open pipe for $f : $!"; while() { chomp; my @line = split /\t/; $line[17] =~ s/^0+//; $line[14] =~ s/^0+//; if(exists($catHash{$line[17]}) || exists($catHash{$line[14]})) { print OUT join("\t", @line) . "\n"; } else { next; } } close(IN); close(OUT);