> >> my @array = (1 .. 100);
> >> my $counter = 0;
> >>
> >> for (@array) {
> >> print "index -> $counter element -> $_\n";
> >> $counter++;
> >> }
> >
> > The other approach is to use a C-style for-loop.
>
> Is there any given advantage of one over the other in
> terms of performance and/o
On Thursday, April 11, 2002, at 05:09 , Jeff 'japhy' Pinyan wrote:
>> my @array = (1 .. 100);
>> my $counter = 0;
>>
>> for (@array) {
>> print "index -> $counter element -> $_\n";
>> $counter++;
>> }
>
> The other approach is to use a C-style for-loop.
Is there any given advantage of one
On Apr 11, James Taylor said:
>How can I get the current index of an array while processing the array
>in a loop? I know I can do it with a counter type function, but I was
>curious if there was a better way of doing this.
That won't be automatic until Perl 6. Your method is fine.
>my @array
How can I get the current index of an array while processing the array
in a loop? I know I can do it with a counter type function, but I was
curious if there was a better way of doing this.
For example:
my @array = (1 .. 100);
my $counter = 0;
for (@array) {
print "index -> $counter elem