Re: looping through an array with for

2012-02-15 Thread Igor Dovgiy
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

Re: looping through an array with for

2012-02-15 Thread Chris Stinemetz
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/

Re: looping through an array with for

2012-02-14 Thread Jim Gibson
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

looping through an array with for

2012-02-14 Thread Chris Stinemetz
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 %