in reply to foreach problem?
Why's it giving unexpected results :foreach ($currentword, @words)
because you have what you'd like to be your control variable, $currentword in the parens, which denote the list foreach will loop through. This means that your control variable is really becoming the first element of the array, and $_ steps into the place you think $currentword is taking. Since $currentword is empty when the foreach starts, you (naturally?) get "" as the first element. If you'd like to test this out, change my $currentword to my $currentword="First Element!" and see what happens.
actually, if you're only using $currentword in this loop, I'd recommend declaring in the loop :This restores $currentword to its rightful throne as control variable.foreach $currentword ( @words) { ... ... ... }
foreach my $currentword ( @words)
|
|---|