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

Re: how should %^H work with lexical pramas

Thread Previous | Thread Next
From:
hv
Date:
March 30, 2006 16:19
Subject:
Re: how should %^H work with lexical pramas
Message ID:
200603310028.k2V0S9F01226@zen.crypt.org
demerphq <demerphq@gmail.com> wrote:
:On 3/30/06, Nicholas Clark <nick@ccl4.org> wrote:
:Im still curious about the case of
:
:   $^H{dooot}=9*3 if $condition;
:
:IE, setting the hint NOT in a begin block?

Setting the hint affects subsequent compiles within that scope: BEGIN
blocks are used to affect normal compiles; non-BEGIN settings should
affect compiles that happen after BEGIN time, ie evals within the
scope of the setting:

  BEGIN { $^H{dooot} = 1 }
  $^H{dooot} = 2;
  eval { is(get_dooot(), 1) };  # block eval: compiled at BEGIN time
  eval q{ is(get_dooot(), 2) }; # string eval: compiled at runtime

What I'm (now) slightly confused about is that the scoping implies
to me that the effect of setting in the BEGIN block should terminate
at the end of the BEGIN block. Clearly that's not what happens, so
I'm not sure if that's because BEGIN is a special not-really-a-block
case, or whether it's that the setting actually upscopes itself a
level. If the latter, that may confuse the non-BEGIN case.

Hugo

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