develooper Front page | perl.perl5.porters | Postings from March 2003

Re: (?{ .. })'s and lexicals: A fix ([perl #9010], [perl #8817], [perl #8030], etc)

Thread Previous
From:
Enache Adrian
Date:
March 16, 2003 12:03
Subject:
Re: (?{ .. })'s and lexicals: A fix ([perl #9010], [perl #8817], [perl #8030], etc)
Message ID:
20030316195929.GA944@ratsnest.hole
On Sun, Mar 16, 2003 at 09:37:51PM +0200, Enache Adrian wrote:
> 1. sub a { my $x; /(?{ $x++ })/ }
> 	=> 	sub a { my $x; { $x++ } }
> 
> 2. sub a { my $x; my $p = qr/(?{ $x++ })/; $_ =~ $p }
> 	=>	sub a { my $x; sub clos { $x++ }; clos }
> 
> 3. sub a { my $x; my $p = '(?{ $x++ })'; /$p/ }
> 	=>	sub a { my $x; eval '$x++' }

More precisely:
3. sub a { my $x; my $p = '(?{ $x++ })'; /$p/ }
	=>      sub a { my $x; eval '$x++'; die "..." if $@ }

Revamping all that to use blocks/full closures/full evals will
have another benefic effect: get one rid of the top_env panic
on Perl_croak()s during the compilation of (?{ .. }) blocks:

$ perl -e '/(?{ " })/'
panic: top_env

(A plethora of tickets are about that)

Regards
Adi

Thread Previous


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