Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: How do I find the position of an element in an array?

by runrig (Abbot)
on Sep 21, 2001 at 22:56 UTC ( [id://113967]=note: print w/replies, xml ) Need Help??


in reply to How do I find the position of an element in an array?

my( $i ) = grep { evaluate($array[$_]) } 0 .. $#array;
Of course, you'd define evaluate() to test for the actual condition you're interested in.

Replies are listed 'Best First'.
Re: Answer: how do I find the position of an element in an unknown array
by runrig (Abbot) on Sep 21, 2001 at 23:00 UTC
    That should probably be:
    my @deletes = grep { evaluate($array[$_]) } 0..$#@array;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://113967]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (1)
As of 2024-04-24 14:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found