Re: the way to get current index of an array

2006-02-28 Thread JupiterHost.Net
The Ghost wrote: sub getIndex { my ($array, $value)[EMAIL PROTECTED]; my $x=0; foreach (@{$array}) { $_ eq $value ? return $x : $x++; } #only works if array has unique items and is slow, but could be easy if it fits your problem #pers

Re: the way to get current index of an array

2006-02-28 Thread The Ghost
sub getIndex { my ($array, $value)[EMAIL PROTECTED]; my $x=0; foreach (@{$array}) { $_ eq $value ? return $x : $x++; } #only works if array has unique items and is slow, but could be easy if it fits your problem #personally, I don't recommend this, but maybe it's wh

Re: the way to get current index of an array

2006-02-28 Thread Bob Showalter
[EMAIL PROTECTED] wrote: hi, perlers, Is there a simple way to get the current index of an array in loop statement? the procondition is you cannot get this information from array element. For example #!usr/bin/perl my @arr = qw/a b c d e/; for(@arr) { print "The No.?? element is $_\n"; }

Re: the way to get current index of an array

2006-02-28 Thread JupiterHost.Net
[EMAIL PROTECTED] wrote: > hi, perlers, Howdy, > Is there a simple way to get the current index of an array in loop yes > statement? the procondition is you cannot get this information from > array element. For example > > #!usr/bin/perl > my @arr = qw/a b c d e/; > for(@arr) > { > pr

Re: the way to get current index of an array

2006-02-27 Thread John W. Krahn
[EMAIL PROTECTED] wrote: > hi, perlers, Hello, > Is there a simple way to get the current index of an array in loop statement? > the procondition is you cannot get this information from array element. For > example > > #!usr/bin/perl > my @arr = qw/a b c d e/; > for(@arr) > { > print "The N