Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Finding index of an entry in an Array

by jrsimmon (Hermit)
on Dec 07, 2007 at 02:04 UTC ( [id://655565]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my $index = 0;
    my $input = $ARGV[0] || 'bar';
    my @repo = qw (foo bar qux);
    $index++ until @repo[$index] eq $input or $index > $#repo; #don't want
    + to loop forever if it's not found
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-19 07:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found