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
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
[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";
}
[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
[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