in reply to How to find the index of an element in an array?

Dear Masters,
Perhaps this is too banal, but TIMTOWTDI!
perl -e ' @foo=('a','b','c', 'd', 'e', 'f', 'g', 'h', 'i'); $str = join("",@foo); $idx = index($str,'g'); print "$str-$idx\n";'
prints:
abcdefghi-6


---
neversaint and everlastingly indebted.......

Replies are listed 'Best First'.
Re^2: How to find the index of an element in an array?
by holli (Abbot) on Sep 06, 2005 at 06:56 UTC
    This fails horribly when the array looks like
    @foo=('a', 'bb', 'ccc', 'dddd', 'e' x 50);


    holli, /regexed monk/