Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Occurence List

by aitap (Deacon)
on Oct 10, 2012 at 17:55 UTC ( #998276=note: print w/ replies, xml ) Need Help??


in reply to Occurence List

Use a hash:

use Data::Dumper; my @list = qw/ 1 1 1 234 234 3 5 5 2 7 6 3 6 8 4 /; my %count; $count{$_}++ foreach @list; print Dumper \%count; __END__ $VAR1 = { '6' => 2, '3' => 2, '234' => 2, '7' => 1, '2' => 1, '8' => 1, '4' => 1, '1' => 3, '5' => 2 };
Sorry if my advice was wrong.


Comment on Re: Occurence List
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2015-09-05 05:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred temperature scale is:










    Results (151 votes), past polls