fgrep -w -f list.txt largefile.txt #### my @list = <$list>; my @large = <$large>; foreach my $test (@list){ print grep (/^$test/,@large); }