CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate: Re: [zapzap] Count number of occurrences in list: Edit Log



Zhris
Enthusiast

Oct 16, 2013, 6:29 AM


Views: 2795
Re: [zapzap] Count number of occurrences in list

Hi,


Code
my %hash; 

%hash = map { $_ => ++$hash{$_} } @l;
# or
grep { $hash{$_}++ } @l;
# or
$hash{$_}++ for (@l);


Chris


(This post was edited by Zhris on Oct 16, 2013, 8:46 AM)


Edit Log:
Post edited by Zhris (Enthusiast) on Oct 16, 2013, 8:45 AM
Post edited by Zhris (Enthusiast) on Oct 16, 2013, 8:46 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives