Of course they're checked at run time, as you say, it can only be effective at run time. I was simply pointing out that no strict 'refs' is not interpreted or executed at run time. The interpreter does not even know that there was such a line in the program, all it knows is that certain operations have had their strict refs bit set to 1 and others haven't. This was probably done using strict but it could also have been doneusing some of the B modules, there's no way to know.

The point being that, for example this code

print $$f; { no strict 'refs'; print $$f; print $$g; } print $$f;
is not compiled down to a series of ops like
print $$f; switch on the strict refs flag; print $$f; print $$g; switch off the strict refs flag; print $$f;

Every dereference op has a flag on it to say whether it should be strict or not so it is in fact compiled down to something like

print ( dereference $f allowing strings ); print ( dereference $f not allowing strings ); print ( dereference $g not allowing strings ); print ( dereference $f allowing strings );

The no strict 'refs' does not perform any action at all at run time and so it's position relative to loops is irrelevant.

Also, every time you say use ... you run the module's import() method. It happens at compile time but it certainly isn't a once-only thing.
I'm not sure what your point is, I think you have misintepreted
any use statement only gets run once no matter where it is

All I meant by this was

use MyModule; # this will be run once at compile time print "hello\n"; use MyModule; # this will be run once at compile time for (1..10) { use MyModule; # this will be run once at compile time print $_; }

Each of the 3 use statements are run once only. If they were require statements then the 3rd one would be run 10 times because when you're dealing with require it does matter where it is.


In reply to Re^7: Using import to generate subroutines by fergal
in thread Using import to generate subroutines by Thilosophy

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.