You operated on a string that is more than 231 chars in length, which is longer than the regex engine can handle. To handle strings that long, upgrade to Perl 5.22 or higher.
perl5220delta:
s///g
now works on very long strings (where there are more than 2 billion iterations) instead of dying with 'Substitution loop'. [GH #11742]. [GH #14190].
Alternatively, you could mess with the line terminator.
perl -pe'BEGIN { $/ = "\n+ " } s/\n\+ \z/ /'
Depending on how many lines start with the sequence, this risks not fixing the problem. So you could use a solution which doesn't read more than one line at a time.
perl -ne'
chomp;
print "\n" if !s/^\+ / / && $. != 1;
print;
END { print "\n"; }
'
Same idea, but shortened at the cost of readability:
perl -pe'print $l if !s/^\+ / /; $l = chop; END { print $l }'
perl -00pe 's/\n\+ / /g' file.txt
. You must be doing something else. – Ambidexter-00
is paragraph mode, meaning readline will use double spacing. – Ambidexter+
. Perhaps it is a coincidence – Ambidexter