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

Re: how should %^H work with lexical pramas

Thread Previous | Thread Next
March 30, 2006 16:19
Re: how should %^H work with lexical pramas
Message ID:
demerphq <> wrote:
:On 3/30/06, Nicholas Clark <> 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.


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