Chris Devers wrote:
On Thu, 13 Jan 2005, Dave Kettmann wrote:
[...] Some of the time I see them say that the [strict / warnings] 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?
No, leave them in, always.
Yep!
There should be little if any noticable speed difference.
Also 100% correct:
I did a benchmark of use strict; use warnings; print 1; vs. print 1;
Benchmark: timing 10000000 iterations of no pragma, w/ pragma...
no pragma: 4.9282 wallclock secs ( 4.79 usr + 0.01 sys = 4.80 CPU) @ 2083333.33/s (n=10000000)
w/ pragma: 4.97848 wallclock secs ( 4.95 usr + -0.01 sys = 4.94 CPU) @ 2024291.50/s (n=10000000)
Rate w/ pragma no pragma
w/ pragma 2024291/s -- -3%
no pragma 2083333/s 3% --
So it costs 3% more every ten million times it runs, the benefits of leaving it in are much more valuabel than 3%/10000000 :)
It may be differnt on your perl/OS/etc but that should give everyone a general idea, and if not then feel free to benchmark it on your OS/Perl...
They're a safety net for developing new code, and they're a safety net for protecting against future breakage. The latter becomes especially important as time goes on, where if you're the one mainting the program you no longer remember how it works, or (more typically) someone else is maintaining it and they have to figure out what your intentions were.
Agreed!
If I'm given code to work with I feel much better if it already ahs strict and warnings, at least I know they put some effort into writing it and it makes my mind rest assured ;p
Having the discipline that strict & warnings enforces ensures that the code should be that much more maintainable in the long term.
So, leave them in. Always.
Couldn't have said it better myself Chris!
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>