in reply to My first perl script is working, what did I do wrong?
Hello killersquirel11. Looks like you've already been given some full rewrites. I just figured I'd give you some smaller points to think about in the future.
my ($headerLine, $prtIndex, $shpIndex, $clrIndex, $sizIndex) = -1
my ($headerLine, $prtIndex, $shpIndex, $clrIndex, $sizIndex) = (-1) x 5;
if() vs unless() i.e.
if ($#ARGV != 0) -> unless ($#ARGV == 0)
if (not -e $inputFile) -> unless (-e $inputFile)
Multiple Variable Declaration can be broken down from:
to:my $headerLine= -1; my $prtIndex = -1; my $shpIndex = -1; my $clrIndex = -1; my $sizIndex = -1;
my ($headerLine, $prtIndex, $shpIndex, $clrIndex, $sizIndex) = (-1) x 5;
C style for loops like:
Can be "Perl-ified" like:sub checkIndices { my $count; for ($count=0; $count<=$#_; $count++){ if($_[$count] < 0){ return (1==0); } } return (1==1); }
sub checkIndices { for my $item (@_){ return (1==0) if ($item < 0) } return (1==1); }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: My first perl script is working, what did I do wrong?
by rjt (Curate) on Nov 08, 2012 at 22:55 UTC | |
by Anonymous Monk on Nov 08, 2012 at 23:48 UTC | |
by killersquirel11 (Novice) on Nov 08, 2012 at 23:58 UTC | |
by marquezc329 (Scribe) on Nov 09, 2012 at 00:29 UTC |
In Section
Seekers of Perl Wisdom