Dave Kettmann wrote:
Hello all,

I have seen in quite a few posts to the list from the non-beginners, who I think all of us beginners appreciate them taking their time to help us true beginners, make some references to the strict and warnings pragmas. So I have a question about them. Some of the time I see them say that the pragmas are good for developing programs/scripts. The way it is worded some times it seems as if after the program is written and in 'production' to take these lines out of the code. Do they slow down how perl processes the programs? Does it hurt to leave them in?

Just a question from a beginner who is trying to progress along the wonderful road of Perl :)

In just about all the code I write, I use strict & warnings (in every package). The exeception is in Module::Build and some of its ancillary modules where we don't use warnings because we try to remain backwards compatable to at least 5.005 and warnings only appeared in 5.006.


However, there is some baggage in using warnings, and some people do remove it from production code. If you're really concerned, I'd suggest benchmarking. If after benchmarking you notice a significant change, you can try something like:

use if $ENV{UNDER_CONSTRUCTION}, strict;
use if $ENV{UNDER_CONSTRUCTION}, warnings;

or even:

BEGIN {
    if ( $ENV{UNDER_CONSTRUCTION} ) {
        for my $m ( qw( strict warnings ) ) {
            require "$m.pm"; $m->import;
        }
    }
}

But, I don't really worry about it. I've never used anything like that in my code. If there are speed problems, there are usually better candidates for optimization. I have never had to remove, or even think about removing, either pragma for speed considerations.


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to