in reply to foreach only for a section of a list
You can use Slices:for (my $i = 0; $i < @somewords -1; $i++) { print " $somewords[$i];\n" }
Or, in some cases, it makes sense to use Loop Control:foreach $core (@somewords[0 .. $#somewords-1]) { print " ${core};\n" }
my $i = 0; foreach my $core (@somewords) { next if ++$i == @somewords; print " ${core};\n" }
TIMTOWTDI
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
|
|---|