in reply to Code Optimization v5.8.1
use strict; use warnings; use diagnostics;
This will do several things. You mentioned that you're (paraphrasing) "so new you don't know what you don't know..."
'use strict;' will force you to learn what it is you don't know; how to use lexical variables and scoping instead of package globals. It will also protect you from the pitfalls of unwittingly using soft references (symbolic refs -- something to leave alone for a good long while). And strictures will protect you from misspelling variable names.
'use warnings;' will cause Perl to warn you when you do things that turn out to often be indicitave of a common mistake. For example, using a variable only once, trying to rely on the value of a variable that never received a value, etc. You've already got warnings with the -w switch on the shebang line, but you get better control with the pragma instead of the commandline switch.
'use diagnostics;' will force Perl to become more verbose by explaining what its warnings and error messages mean, in greater detail.
If you do that, you will suddenly find yourself needing to revamp the script a little. Feel free to ask questions if you need an explanation of the outcome.
Dave
|
|---|