I was not precise regarding strict and warnings. Neither one of these things is purely compile time or run time.

"strict" has 3 categories:
- refs
- vars
- subs

'refs' has to do with symbolic references and YES, is a runtime warning. The other two: vars and subs are compile time checks. Far and away the most frequent thing that I see with "strict" is a 'vars' error, problem. 'subs' just disallows barewords.

my $ref ="foo"; #symbolic reference to some global variable print $$ref; #this sort of thing is what strict 'refs' won't like
I would argue that although this check happens at runtime, the use of symbolic references is so seldom and what Perl does to check this is so fast that this is just lost in the overall performance scheme of things. Essentially if you don't have any symbolic references, checking happens at compile time. I think one would be hard pressed to find any program what runs significantly slower when "using strict;"

On the other hand "use warnings;" turns out not to be purely runtime either. There are some compile time aspects to this in addition to the run time checks. However the "main event" are the runtime checks. And there are a whole bunch of them! Take a gander at the section on warnings in Chapter 31 of "Programming Perl", the is a cool diagram showing the categories.

I have read that performance hit could be as much as 30% in some outlier cases with "use warnings". I personally have not spent a lot of time worrying about this or benchmarking code, because I feel that the benefits of using both strict and warnings outweigh any kind of performance hit entailed.

So I guess the most accurate statement would be that "use strict" happens mainly at compile time and "use warnings" happens mainly at runtime.


In reply to Re^5: Subroutine references inside of a hash with arguments. by Marshall
in thread Subroutine references inside of a hash with arguments. by shift9999

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.