$pre = "https://biblehub.com/greek/"; $var = "a, b, c, d, e, f, g, h"; $post = ".htm"; @array = split (/, /, $var); #$out = system "curl --fail https://biblehub.com/greek/2.htm"; #print "\n\n\t\$out: $out"; open OUT, ">out/results.txt"; foreach $xx (1611 .. 1613) { foreach $var (@array) { $string = $pre . $xx . $var . $post; $out = `curl $string`; if ($out =~ /We're sorry, we were not able to find that passage./) { last } else { print OUT "\$xx: $xx. \$string: $string."; } } } close OUT;