I'd be inclined to just iterate over the index:
foreach my $idx ( 0 .. $#somewords - 1 ) { print " $somewords[$idx]\n"; }
The slice technique is also nice though:
foreach my $core ( @somewords[ 0 .. $#somewords - 1 ] ) { print " $core\n"; }
Dave
In reply to Re: foreach only for a section of a list
by davido
in thread foreach only for a section of a list
by dizou
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |