while(my$line=){ if ($line=~m/$chrom/){ #not sure how to move to the next few lines of where I can test that $s<$start my ($s,$prob)=split(/\s+/,$line); if ($s<$start) { next; } else{push @values,$prob;} } }