Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

sum of matching elements in an array

by sickboy
on Apr 13, 2001 at 10:42 UTC ( #72305=perlquestion: print w/replies, xml ) Need Help??

sickboy has asked for the wisdom of the Perl Monks concerning the following question:

say i had a list of friends names with their favorite number.

I just want to know what numbers were people's favorites and
how many times each number was picked.
For the above example the output should be:
1   1 times
21  3 times
7   2 times


Replies are listed 'Best First'.
Re: sum of matching elements in an array
by dvergin (Monsignor) on Apr 13, 2001 at 11:13 UTC
    sickboy, this has the feel of a homework assignment... But whether or not that is the case, you will receive much better help if you take a stab at the problem yourself.

    For starters, without worrying about producing any Perl code, how would you break this task down into several smaller tasks. Just state the sub-tasks in plain English.

    Once you have this outline, take a shot at the first task and show us your work and describe what happened or where you are stuck and why.

    Working in steps this way, you will receive generous help. Ask us to solve your problem for you and the responses will be a bit less patient.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2019-09-19 07:18 GMT
Find Nodes?
    Voting Booth?
    The room is dark, and your next move is ...

    Results (240 votes). Check out past polls.