my $splitpoint = index $html[$i], '', 500_000; if( $splitpoint >= 0 ) { my $fragment = substr $html[$i], 0, $splitpoint + length '', ''; ...