develooper Front page | perl.perl5.porters | Postings from October 1999

Re: regexp in 5.005_61: (?{...})

Thread Previous | Thread Next
From:
M.J.T. Guy
Date:
October 1, 1999 10:20
Subject:
Re: regexp in 5.005_61: (?{...})
Message ID:
E11X6MW-0005Ep-00@ursa.cus.cam.ac.uk
"Konovalov, Vadim" <vkonovalov@lucent.com> wrote
> While ramblering in Perl's regexp source I've noticed that (?{...})
> construction is parsed in regcomp.c in too simplified way.

> perl -e '/(?{print "Hello{"})/'
> explains:
> Sequence (?{...}) not terminated or not {}-balanced at -e line 1, within pattern
> /(?{print "Hello{"})/: Sequence (?{...}) not terminated or not {}-balanced at -e line 1.

It's interesting that in other analogous cases, Perl gets this right.
For example

         perl -we '@{"{"} = (1..3);print qq(@{"{"}\n)'

prints

         1 2 3

So I'd call this a bug.

But you can circumvent it with an escape:

         perl -e '/(?{print "Hello\{"})/'
         Hello{


Mike Guy

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About