Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Finding index of an entry in an Array

by Anonymous Monk
on Dec 07, 2007 at 16:33 UTC ( #655688=note: print w/replies, xml ) Need Help??


in reply to Finding index of an entry in an Array

a caching approach to returning all indices of an item in an array:

perl -wMstrict -e "my @repo = qw(foo bar qux bar bar zot); my %repo_indices; push @{ $repo_indices{$repo[$_]} }, $_ for 0 .. $#repo; print qq(@{ $repo_indices{bar} });" 1 3 4

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://655688]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2018-05-27 11:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?