I spend some time trying to find my mistake while solving that problem:
I have a text block, which consists of two different types of lines: 1) lines which starts with /[^#\n]*#/, 2) any other lines.
Then I need to glue all consecutive lines of second type. In other words I need to delete newlines between them.
Below it is a simplified problem, and me trying to solve it:
use warnings;
use strict;
my $m = (1 << 15) + 1; # 32769
my $_="#\n" . "A\n" x $m . "#\n";
s/
^[^#].*?$ # find a line which haven't "#" at it beginning.
(?:\n[^#].*?$)* # find consecutive n (n>=0) such lines
/
$a=$&,
$a=~y{\n}{}d, # delete newlines
$a
/megx ; ## multiline, eval, global, comments
my $n = () = /\n/sg; # calc the number of occurences of "\n"
print $n
# ANSWER: 4, My expectation was: 3
Perl v5.16 STDERR says "Complex regular subexpression recursion limit (32766)".
My questions are: 1) can't we still change this limit by our hands? (Seems that Python allows so). UPD: 2) shouldn't it be an error if the answer which I gain is incorrect, and a knowledge about these limits are specific in my opinion, and me using "strict"? |