Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

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

Replies are listed 'Best First'.
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?


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://935478]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2018-03-20 21:47 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (259 votes). Check out past polls.