in reply to Re: Finding index of an entry in an Array
in thread Finding index of an entry in an Array
Update: Fletch noted an issue, when I was quickly testing on the command line I wasn't assigning to a variable, just printing (e.g. print grep { ... } 0 .. $#array, which evaluates in list context, not scalar context as I through up here with the assignment. Adding the parens clears that up. (Thanks Fletch).my @array = qw(dog cat mat bat hat); my ($idx) = grep { $array[$_] eq 'bat' } 0 .. $#array;
---
s;;:<).>|\;\;_>?\\^0<|=!]=,|{\$/.'>|<?.|/"&?=#!>%\$|#/\$%{};;y;,'} -/:-@[-`{-};,'}`-{/" -;;s;;$_;see;
Warning: Any code posted by tuxz0r is untested, unless otherwise stated, and is used at your own risk.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Finding index of an entry in an Array
by Fletch (Bishop) on Dec 07, 2007 at 03:45 UTC |