Free Newsletters :

Scripting Best Practices

September 4, 2008
By

Juliet Kemp



Juliet Kemp



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.

Tags: IT, VAR, email, job





IT Offers












 

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs