develooper Front page | perl.perl5.porters | Postings from May 2016

Re: [perl #128225] substitution within (?{}) causes segmentationfault

Thread Previous | Thread Next
Dave Mitchell
May 30, 2016 12:08
Re: [perl #128225] substitution within (?{}) causes segmentationfault
Message ID:
On Mon, May 23, 2016 at 10:48:26AM -0700, Daniel Șuteu wrote:
> my $str = "foo";
> $str =~ /(?{ s{}{} })/;

As has been pointed out elsewhere in this ticket, an empty pattern
is interpreted as the "last successful match". The re-eval
mechanism takes this as being the currently executing pattern,
and so you get infinite recursion.

Marking the currently executing pattern as 'last successful'
is necessary within an re-eval so that things like $1 are visible:

    #prints "a"
    "ab" =~ /(.)(?{ print "[$1]\n" })/;

"You're so sadly neglected, and often ignored.
A poor second to Belgium, When going abroad."
    -- Monty Python, "Finland"

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About