Home | Hardware | Internet News |Web Hosting |IT Management |Network Storage
LinuxPlanet
Search 
  Power Search | Tips 

 Front Door
 Discussion
 LinuxEngine
 Opinions
 Reports
 Reviews
 Tutorials
 News
 Technology Jobs

 Browse by subject.
Free Newsletter

Java/Open Source Daily
Linux Today
More Free Newsletters

Be a Commerce Partner


















internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

Print this article
Email this article

   LinuxPlanet / Tutorials







Scripting Best Practices
Let Perl Help You

Juliet Kemp
Tuesday, September 2, 2008 10:33:54 AM

A perl-specific tip: the single most helpful thing you can do for yourself is to use these lines in every script:

#!/usr/bin/perl -w
use strict;
The -w flag turns on warnings. This means that if perl sees something that it thinks looks dubious (e.g. variables mentioned only once), it'll tell you so.

use strict requires you to declare all your variables before (or at least at) their first use. Thus,

my $newvar;
// some stuff
$newvar = 3;  
will be AOK, as would my $newvar = 3. But $newvar = 3 without the declaration (or a local declaration) will cause an error. This is fantastic for avoiding typos or variable name brain-blips: if you declared $newvar and then use $newcar a few lines down, you'll be warned.

Next: Comments Are Not Dangerous »

Skip Ahead

1 Treat Your Variables Right
2 Let Perl Help You
3 Comments Are Not Dangerous





Linux is a trademark of Linus Torvalds.


internet.com home | search | help! | about us

Jupiter Online Media

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers