Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
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 lurking in the Monastery: (5)
As of 2017-12-11 19:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (310 votes). Check out past polls.

    Notices?