Hi Jim,
Well, instead of asking at each step, whether the last element is processed
or not, it's slightly better to exclude it from the loop:
for my $i (0..$#keyFields - 1) {
printf "%s %s", $keyFields[$i], $match;
}
printf "%s %s", $keyFields[-1], $lastmatch;
But yes, I guess your last approa
Thank you Jim.
Your suggestions worked perfectly!
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
At 9:08 PM -0700 2/14/12, Chris Stinemetz wrote:
I have a for loop I would like to alter so that when the iteration
reaches the last element in the array the varibale $lastmatch is
passed to printf instead of $match.
Does anyone have any suggestions?
my $match = "GE 0 AND ";
my $lastmatch = "GE
I have a for loop I would like to alter so that when the iteration
reaches the last element in the array the varibale $lastmatch is
passed to printf instead of $match.
Does anyone have any suggestions?
my $match = "GE 0 AND ";
my $lastmatch = "GE 0";
for my $i (0 .. $#keyFields) {
printf "%s %