in reply to Re: how do i find the index of a specific array value?
in thread How do I find the index of a specific array value?

Sorry, merlyn. Perhaps you meant:
my ($index) = grep $array[$_] eq $search_for, 0 .. $#array;


japhy -- Perl and Regex Hacker

Replies are listed 'Best First'.
Re^2: Answer: how do i find the index of a specific array value?
by Anonymous Monk on Aug 12, 2014 at 05:53 UTC
    grep $array$_ eq $search_for, 0 .. $#array; will return matched array which stores the index of the matching words. my @index_arr = grep {$array$_ eq $search_for} 0 .. $#array; or my @index_arr = grep $array$_ eq $search_for, 0 .. $#array; foreach (@index_arr) { print "matching position = $_\n"; }
Re: Re: Answer: how do i find the index of a specific array value?
by merlyn (Sage) on Apr 26, 2001 at 04:06 UTC