Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Help on array element counting

by Zaxo (Archbishop)
on Oct 27, 2003 at 19:36 UTC ( [id://302490]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    for my $fruit (qw{MANGO APPLES}) {
        print $fruit,
              ' => ',
              scalar( grep { $fruit eq $_ } @fruits),
              $/;
    }
    
  2. or download this
    my %fruit_count;
    $fruit_count{$_}++ for @fruits;
    for (qw{MANGO APPLES}) {
        print $_, ' => ', $fruit_count{$_}, $/;
    }
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-24 19:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found