Number one: when in doubt use perl -w, or replace #!/usr/bin/perl with #!/usr/bin/perl -w this will give you all kinds of helpful diagnostics
when things don't seem to be happening as you'd expect them to.
Number two: use use strict; just toss that in at the top of your program and it will force you to declare your variables before you use them. To declare them all you have to do is something like the following:
Number two: use use strict; just toss that in at the top of your program and it will force you to declare your variables before you use them. To declare them all you have to do is something like the following:
my $stuff; my @array; my %hash; my ($count,$max,$min,$avg); #this initializes several scalars at onceThis can save you countless hours later if you've mistyped a variable name. You'll know about it.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Some things that will make your life easier as a Perl coder
by chrism01 (Friar) on Nov 13, 2007 at 23:58 UTC | |
by Anonymous Monk on Jul 23, 2008 at 06:32 UTC | |
Re: Some things that will make your life easier as a Perl coder
by dannyd (Sexton) on Feb 23, 2011 at 12:16 UTC |
Back to
Tutorials