Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: no strict refs for blocks?

by ikegami (Pope)
on Nov 02, 2011 at 19:26 UTC ( #935478=note: print w/ replies, xml ) Need Help??


in reply to no strict refs for blocks?

[ This post gives some of the technical details in case someone is interested. ]

Not only does it work, a fair amount of effort went into making it work.

use strict; and no strict; are executed at compile-time, yet the "refs" check is a run-time check. This is done by attaching hints to some opcodes (the same opcodes that provides line numbers for warnings and such, I think). Telling the parser which hints to use is done via $^H. Peeking at the hints in effect can be done using caller.

The hints are lexically scoped in the parser in order to make the effects of this pragma lexically scoped too.

$ perl -E' my @hints = ( [refs=>0x2], [subs=>0x200], [vars=>0x400] ); sub hints { my $h = (caller(0))[8]; my @h = map { $h & $_->[1] ? $_->[0] : () } @hints; @h ? join(",", @h) : "[none]" } say hints; # [none] use strict; say hints; # refs,subs,vars { say hints; # refs,subs,vars no strict; say hints; # [none] } say hints; # refs,subs,vars ' [none] refs,subs,vars refs,subs,vars [none] refs,subs,vars


Comment on Re: no strict refs for blocks?
Select or Download Code
Re^2: no strict refs for blocks?
by Anonymous Monk on Nov 02, 2011 at 22:44 UTC

    This is done by attacking hints to some opcodes

    With sticks or stones?

      Fixed

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://935478]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (3)
As of 2014-09-15 02:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (145 votes), past polls