open my $fhConditions, "<", "1.txt" or die "Epic Fail: $!"; use strict; use warnings; open my $fhCharacters, "<", "2.txt" or die "OMG Fail: $!"; my $length = 250; while (my $line = <$fhConditions>) { chomp $line; my ($strand, $chr, $position) = split(' ', $line); $position += $length if $strand == 0; $position -= $length if $strand == 1; seek $fhCharacters, $position, 0; my $data; read $fhCharacters, $data, $length; if ($data =~ m/$AAGCTT/) { print "Y" "\n"; else print "N" "\n"; } }