use warnings; use strict; my $List1 = <; close $in1; my $hitCount = 0; open my $in2, '<', \$List2 or die "Failed to open List2: $!"; while (<$in2>) { chomp; next unless length; my $data2 = $_; $hitCount += grep {abs ($data2 - $_) <= 0.2} @data1; } close $in2; print "Found $hitCount matches\n"; #### Found 6 matches