Well, I got the out put that I wanted. the use Data::Dumper; call really helped with my debugging, thanks for the tip. I understand what's going on except for the printing and the foreach loops, can someone break that down for me? Also, any other resources on foreach loops? Thanks in advance, -stu
foreach is pretty simple. It's just a way to iterate over a list of things, dealing with them one at a time. Here's a few simple examples:
foreach my $number (1, 2, 3, 4, 5) {
# in here we work on $number which will hold 1 then 2 then 3...
print "$number.\n";
} # $number goes out of scope heremy $average = 0; # declare outside loop to keep a running total
for my $number (1, 2, 3, 4, 5) { # foreach can also be spelled for
$average += $number;
}
$average /= 5; # getting an average of 3my @letters = qw(a b c d);
foreach (@letters) { # if no variable is given, $_ is used
tr/a-z/A-Z/; # a lot of operations default to $_, like transliterate
print "$_\n";
}
print "@letters\n"; # foreach aliases variables, so @letters was changed!
#foreach can also be used as a statement modifier print foreach 'A'..'Z'; # print also defaults to $_
All of this is basic Perl, so just about any beginning resource is going to have plenty of material here. Learning Perl is a popular first choice in the book department.
James
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
