in reply to Finding index of an entry in an Array
It's worth noting that in your example, bar is at index 1, not index 2.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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Finding index of an entry in an Array
by dwu (Monk) on Dec 07, 2007 at 02:57 UTC |