Re: counting word occurances



Rodrick Brown wrote:
> apple
> orange
> pear
> pear
> magno
> apple
>
> Given the following data can someone show me example code on how to
> count how many of each different fruit

Well, assuming @foo contains the list of fruit, then

for (@foo) {
$bar{$_}++;}

will place the count in %bar.

> output should be somehting like

The rest is left as an excercise.

jue


.



Relevant Pages

  • Re: Flystrike is here
    ... tree of each variety and draw your net widely. ... pear, plums, damson, cherry, medlars and the old fruit types. ... ISTR pollination is an issue with fruit trees. ... There is a *William Lamb* apple produced by one of my forebears but I wouldn't recommend it. ...
    (uk.business.agriculture)
  • Re: Make one list from 2 unique quiries
    ... Select Column1 as Fruit from table 1 ... (might have to try a Union ALL and look at select distinct, ...
    (microsoft.public.access.queries)
  • The World of Fruit Labels
    ... The web's first fruit label site. ... 4015 Cape Late Top Red [apple] ... 4173 Copefrut ROYAL GALA [apple] ... 4408 Asian Pear ...
    (rec.gardens)
  • Re: [opensuse] question about zypper dup
    ... Similar if a pear can be compared to apples.. ... Malus is a genus in the subfamily Maloideae (a subfamily of ... and apple species are so similar in shape and color of the fruit that you ...
    (SuSE)
  • counting word occurances
    ... how many of each different fruit ...
    (comp.lang.perl)