#!/usr/bin/perl use strict; use warnings; use 5.012; use Data::Dumper; my $large =< 1} <$fh1>; close $fh1 or die $!; open my $fh2, "<", \$large or die $!; while( <$fh2> ){ my ($test) = /^(\d+)/; # if $test is in the hash # then $stopwords{ $test } == 1 or true print unless $stopwords{ $test }; } close $fh2 or die $!; #print Dumper \%stopwords;