## OP specified 'last
' tag, ## so assume there can be more than oneor end of string my @pre = ( $VAR1 =~ m{..block ## find allblocks, using non-greedy .*? and also ## get \n in the case where the html ends with a newline and no## anchor to non-capturing match for closing
(.*?\n?)(?:|$)}isg ); ## we want the last one my $new_output = pop @pre;