Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Find last position of an element in array

by kcott (Archbishop)
on Mar 29, 2022 at 05:45 UTC ( [id://11142481]=note: print w/replies, xml ) Need Help??


in reply to Find last position of an element in array

TMTOWTDI

$ perl -E ' my @array = (1,1,1,2,2,2,2,2,3,3,3,4,4,4,4,4,4,5,5,6); { local $" = ""; say rindex "@array", "4"; } say "@array[16, 17]"; ' 16 4 5

In your example data, you show only elements with single digits. The solution I presented assumes this is representative data.

— Ken

Log In?
Username:
Password:

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

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

    No recent polls found