[Melbourne-pm] Remove use warnings; use strict; in production ?

Paul Fenwick pjf at perltraining.com.au
Tue Jun 22 03:23:00 CDT 2004

G'day Scotty / All,

Scott Penrose wrote:

> I recently read the following in a new bit of perl development:
> "You will want to remove 'use strict' and 'use warnings' after you are 
> finished testing to eliminate their overhead in production."
> Is it true that it adds overhead ? I thought it altered behaviour only ?

'use diagnostics' definitely adds overhead, and should be removed for 
production.  It parses the perldiag file upon program start-up.

The effect of 'use strict' is only to make tweaks to $^H and set (or 
unset) a number of flags.  These are compile-time hints to the Perl 
interpreter.  Once Perl is actually running, these hints have no effect. 
  (Unless you try compile more code with string eval).

Likewise, 'use warnings' modifies the special variable ${^WARNING_BITS}. 
  My understanding is that this bitmask is checked whenever a warning 
would be generated by Perl.  Indeed, if you use warnings then you're 
likely to fix code that may invoke the warning mechanism, which I expect 
would result in faster code.  :)

You will definitely experience some overhead if your code is generating 
lots of warnings, but in that instance the code should be fixed, or a 
specific 'no warnings' used for the desired block of code.



Paul Fenwick <pjf at perltraining.com.au> | http://perltraining.com.au/
Director of Training                   | Ph:  +61 3 9354 6001
Perl Training Australia                | Fax: +61 3 9354 2681

More information about the Melbourne-pm mailing list