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

Re: how should %^H work with lexical pramas

Thread Previous | Thread Next
From:
demerphq
Date:
March 30, 2006 09:45
Subject:
Re: how should %^H work with lexical pramas
Message ID:
9b18b3110603300945k877cba8wb58da2699d5efa93@mail.gmail.com
On 3/30/06, Nicholas Clark <nick@ccl4.org> wrote:
> On Wed, Mar 29, 2006 at 03:15:17PM +0200, Rafael Garcia-Suarez wrote:
> > Nicholas Clark wrote:
> > > And given that you might want to implement your pragma with more than one
> > > level of subroutine, I infer that you might need to get at $^{foo} from
> > > somewhere up your caller's scope. This starts to sound like the correct
> > > hash should be returned as another value from caller.
> >
> > Just like the warnings bitfield, yes.
>
> So, basically, if this test passes, user defined lexical pragmas are go:
>
> use warnings;
> use strict;
> use Test::More tests=>5;
>
> sub get_dooot {
>     my @results = caller(0);
>     $results[10]->{dooot};
> }
>
> {
>     is(get_dooot(), undef);
>     BEGIN {
>         $^H{dooot} = 1;
>     }
>         is(get_dooot(), 1);
>
>     BEGIN {
>         $^H{dooot} = 42;
>     }
>     {
>         {
>             BEGIN {
>                 $^H{dooot} = 6 * 9;
>             }
>             is(get_dooot(), 54);
>         }
>         is(get_dooot(), 6 * 7);
>     }
>     is(get_dooot(), 6 * 7);
> }
>
> __END__
>
> ?
>
>
> (in that at runtime you can read the value that %^H had in that scope, with
> %^H propagating correctly into blocks, and behaving correctly when redefined
> within a block)

Im still curious about the case of

   $^H{dooot}=9*3 if $condition;

IE, setting the hint NOT in a begin block?

Yves


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

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