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

Re: [PATCH] Tweaks so that miniperl.exe doesnt croak while building perl.exe

Thread Previous
From:
demerphq
Date:
March 7, 2007 10:03
Subject:
Re: [PATCH] Tweaks so that miniperl.exe doesnt croak while building perl.exe
Message ID:
9b18b3110703071003i7d274055x7ad4973475ff8af4@mail.gmail.com
On 3/7/07, Nicholas Clark <nick@ccl4.org> wrote:
> On Wed, Mar 07, 2007 at 05:41:38PM +0100, Rafael Garcia-Suarez wrote:
> > On 07/03/07, demerphq <demerphq@gmail.com> wrote:
> > >Attached patch will get the show on the road for building, but won't
> > >fix the minitest failures (ill followup with a patch for that).
> >
> > Thanks, applied as #30496.
> >
> > Note that this glob failure is now back :
> > $ bleadperl -wle 'print*-{HASH}{foo}'
> > Can't locate object method "FETCH" via package
> > "re::Tie::Hash::NamedCapture" at -e line 1.
> >
> > That's because the tied hashes %+ and %- are always created, even when
> > the variable requested is @+ or $-. Unfortunately if I try to create
> > the hashes only when requested, regexp tests start to fail :-(
>
> Odd. Why does that fail that way, when %! fails this way:
>
> $ ./perl -wle 'print*!{HASH}{foo}'
> Can't use an undefined value as a HASH reference at -e line 1.
>
> Aha:
>
> $ ./perl -wle '$!; print*!{HASH}{foo}'
> Can't locate Errno.pm in @INC (@INC contains: /home/nick/snap5.9.x-30492/lib/perl5/5.9.5/i386-freebsd-thread-multi /home/nick/snap5.9.x-30492/lib/perl5/5.9.5 /home/nick/snap5.9.x-30492/lib/perl5/site_perl/5.9.5/i386-freebsd-thread-multi /home/nick/snap5.9.x-30492/lib/perl5/site_perl/5.9.5 .) at -e line 1.
> BEGIN failed--compilation aborted at -e line 1.

These two can be explained by the following code in gv.c at line 1199

	    if (sv_type == SVt_PVHV)
		require_tie_mod(gv, "!", newSVpvs("Errno"), "TIEHASH", 1);

> So *+ and *- are still not behaving in quite the same way as *!
>
> $ ./perl -wle 'print*-{HASH}{foo}'
> Can't locate object method "FETCH" via package "re::Tie::Hash::NamedCapture" at -e line 1.
> $ ./perl -wle '$-; print*-{HASH}{foo}'
> Can't locate re/Tie/Hash/NamedCapture.pm in @INC (@INC contains:
[....]

Ah right. Interesting. The reason is because in the case of $! the tie
is done by ext/Errno/Errno.pm itsef. The second last line of
Errno_pm.PL is

tie %!, __PACKAGE__;

Wheras the code in gv.c for %- and %+ does the tie in C code in the
core and not in re/Tie/Hash/NamedCapture.pm. It didnt occur to me to
do the tie in re/Tie/Hash/NamedCapture.pm actually.....

Yves



-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

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