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

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

Thread Previous | Thread Next
M.J.T. Guy
October 1, 1999 10:20
Re: regexp in 5.005_61: (?{...})
Message ID:
"Konovalov, Vadim" <> 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)'


         1 2 3

So I'd call this a bug.

But you can circumvent it with an escape:

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

Mike Guy

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