in reply to foreach only for a section of a list
perl -e '@set=qw(a b c d);for (@set[0..$#set - 1]){print "$_\n";}' a b c [download]