Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Code Optimization v5.8.1

by davido (Cardinal)
on May 20, 2004 at 17:12 UTC ( [id://355021]=note: print w/replies, xml ) Need Help??


in reply to Code Optimization v5.8.1

At the top of your script, right after the shebang line, put the following three lines:

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://355021]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-25 07:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found