Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2018-09-24 02:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Eventually, "covfefe" will come to mean:













    Results (191 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!