[ 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

In reply to Re: no strict refs for blocks? by ikegami
in thread no strict refs for blocks? by Sewi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.