cyberconte has asked for the wisdom of the Perl Monks concerning the following question:

This question builds upon the previous question located here. This time, theres a newline in the line, as such:
my $string = "16 abc\ndefghijklmnopqrstuvwxyz";
I found that adding the newline broke the following answer:
my ($len,$substring) = ($string =~ /^(\d+) ((??{".{$1}"}))/s);
I did some reading up on the experimental postponed regexp, but it doesn't look like theres a '/s' equivilant for the postponed section.

Am i cursed to de-obfuscation with this kind of match?

Thank you for your answers!

Replies are listed 'Best First'.
Re: Using previous match in the same matching regexp (now with newlines!)
by Aristotle (Chancellor) on Nov 18, 2005 at 15:50 UTC
    my ($len,$substring) = ($string =~ /^(\d+) ((??{"(?s).{$1}"}))/s);

    See perlre on (?imsx-imsx).

    Makeshifts last the longest.

      Thank you, wise one :-) Not only for the answer, but the reference.