See, the thing is that without use strict you can't be sure that _all_ of your variables are declared. You may have missed one or two.
Yes, and? Is that a bad thing for a script has been working for some time already?
Well that all depends on how well the program has been tested. Just because it's been running successfully for some time, that doesn't mean that it's been down every possible execution path. There could be a big bug ready to bite you on the very next run.
And I'm not saying that use strict will necessarily find that bug. But it's one tool that is great for preventing some particular classes of bugs.
"use strict" is a tool, not an end to it self. And it isn't a magic wand that will create correct programs for you.
You're absolutely right. And I hope I never gave the impression that I thought otherwise.
--
<http://www.dave.org.uk>
"The first rule of Perl club is you do not talk about
Perl club." -- Chip Salzenberg
| [reply] |
Yes it is a "bad thing". If it is a warning you expected, then things are probably okay. However in this case it seems that the individual was not expecting warnings, and so I would worry. Code that spews unexpected warnings, but seems to work anyway... Yikes! Just removing warnings and putting it back into place is like burying your head in the sand and hoping that all those flashing lights don't mean anything. | [reply] |
True, but OTOH, it can save you a lot of work when you:
a) Treat variables as though they have values in them, but they are not initialised
OR
b) Use the wrong form of a variable (@list, $list, %list -- especially easy when you a referring to specific items in a list/hash, i.e. preceeded by $)
I would say you are better off leaving strict _on_, unless you have a good reason to turn it off. Otherwise, you can easily spend considerable time debugging something that strict would have warned you about straight up. It's not a magic wand, but it is a nice solid fence that protects you from lack-of-caffeine errors :-) | [reply] |
| [reply] |
Hmm, I wonder what I will see if I put in use strict... <tappity tap>
Yikes! Where are all these warnings coming from?! <thinks>
Oh well, if I remove the use strict they go away.
<tappity tap... slams head into hole in sand.>
| [reply] [d/l] |
How much debugging do you expect from a script that has been running fine for 5 months?
You would be amazed.
My experience is that the process of adding strict.pm to any lengthy script that doesn't have it already goes quickly (because it is largely mechanical), and generally fixes several bugs. (In particular you find that "has been running fine" often means, "Shit, that caused the problem I was having?") It may or may not fix the one I started out looking for, but if it doesn't then I generally come out with a pretty good picture of how the code works, and my development time on that code will be faster.
| [reply] |