Note that use strict also has run-time effects (the strict 'refs'; part), so removing the use strict; line might cause trouble in some conditions that you didn't come across while testing. So leave it in.
Also note that most of the time some other module that you use uses strict, so there's no significant speed or memory gain when you remove it from your script. So don't remove it. | [reply] [d/l] [select] |
I would leave them in the production code. Worst case, the users will report the warnings you should have fixed before release, and justify a maintenance update.
| [reply] |
Well, it will have an impact, but mostly if it actually triggers a warning/error - because then it does work.
But it will only do extra work if there's a problem, and further more, if such tiny resource uses are important for the overall running time of your program, you shouldn't have used Perl in the first place.
It's like after having choosen the Winnebago over the Ferrari, you wonder whether driving with side mirrors impacts its performance. (The answer to that is "Yes, side mirrors impact performance, but who cares about the difference, and wouldn't it be much better to leave them on in the first place?") | [reply] |
There's a famous observation to the general effect:
The last bug has been eradicated when the last user stops using your program.
Leave strict and warnings in!
Contrariwise, in the case of a web page or ap, you probably do want to remove/comment out instructions like use CGI::Carp qw(fatalsToBrowser); because if you leave them in, you may give more help than you intended to someone trying to develop an exploit. | [reply] [d/l] [select] |
There's very little upside to taking it out and potentially major downside when you miss runtime errors. I'd leave strict and warnings in. | [reply] |
There's no point in removing strict, that is mostly a compile time check anyway; and if something really goes haywire, like using a hash entry as a reference (in a complex data structure) when it has already been assigned a string value, you don't really want it to go on. Without strict, Perl would use that string as the name for a global variable... Eventually it could even do serious damage to your data in the database.
As for warnings, that's something else. There have been numerous arguments about it, and there may be valid reasons to disable it in production code. The most important reason that suddenly warnings start to appear, is that an upgrade of Perl could make things that didn't produce a warning before, but do in the new Perl version. For a command line script, that is not so bad (on the contrary, in scripts for my own use they tend to point to irregular data), but if running on a web server, that suddenly could start to cause server errors. Ouch.
If anything, on a web server, make sure the warnings don't produce anything that the user sees, even if it doesn't cause an error. It's no use to him. Make them go to an error log.
| [reply] [d/l] |