for my $stop(0..scalar(@array)-1){ my $tmp_str = join(',', @array[0..$stop]); my $content = get($url . $tmp_str); if ($content) { print "Test: ", $tmp_str, "\n"; } }