Since you described this as your first Perl program, let me
comment on your loop. The others have given good advice
for the data structures, so I'll just make a quick suggestion
about your actual code.
You have:
$n == 0;
for (loop condition){
$n++
}
- Use = for assignment, == for testing. This line
doesn't actually do anything, except cause a warning. It
tests whether $n (an undefined value) is equal to zero.
- On the subject of warnings, you are running with
warnings enabled, right? <nobr>#!/usr/bin/perl -w</nobr>
at the top of your script will enable many useful warnings.
Don't leave home without it. :-)
- On the subject of global variables ($n is a global, in
your code), don't use them. Adam has <nobr>use strict; #Always</nobr>
in his code. This is a good idea. It will help you avoid
problems.
- Looping: Here is a slightly more idiomatic way to do
your loop:
for my $Idx (0 .. $#combo){
print "SKUID:$skuid[$Idx]\n";
print "NAME:$name[$Idx]\n";
print "PRICE:$price[$Idx]\n";
}
In other words, for each index in @combo (the 0 .. $#combo part),
set $Idx to that index and run the body of the block. This
accomplishes the same thing as your code, but doesn't leave
an unused variable ($n) lying around. It specifically uses
the index of each element in @combo, which makes the code
easier to follow and maintain. Besides, it looks so much
cooler... ;-)
Welcome to Perl in general and Perl Monks in specific. We're
glad to have you.
Russ
Brainbench 'Most Valuable Professional' for Perl