[ltp] perl question:

ROOT, DAN linux-thinkpad@www.bm-soft.com
Wed, 23 May 2001 08:02:44 -0700


I know this has little to nothing to do with Linux on ThinkPads other than I
use my ThinkPad for school, but thought I might ask anyway.  For my class I
have created a random numeric array which has 10 elements.  I am suppose to
do a few things with it, but the one thing I seem to be a little stumped on
is finding the most common occurrence of an element and then returning it's
value.

Example:

@array = 2 4 6 3 4 8 1 9 7 5

Mode = 4

How do I capture that "4" is the most common element of the array?  I have
tried using grep and a loop, but I am not getting the results I had hoped
for.  Any pointers from anyone would be muchly appreciated.

Thanks!

Dan Root
Safeco Information Systems
danroo@safeco.com
206-545-3250



----- The Linux ThinkPad mailing list -----
The linux-thinkpad mailing list home page is at:
http://www.bm-soft.com/~bm/tp_mailing.html