I couldn't understand anything, but thank you very much! :-)
I could use the other solutions very easy, but now I have another problem. I
should try to understand your code.

Cheers.
Teddy,
[EMAIL PROTECTED]

----- Original Message -----
From: "drieux" <[EMAIL PROTECTED]>
To: "cgi" <[EMAIL PROTECTED]>
Sent: Sunday, May 19, 2002 6:47 PM
Subject: Re: Counting the elements of an array



On Saturday, May 18, 2002, at 07:09 , Tagore Smith wrote:

> You're on the right track. Try something like this:
>
> my @array=("aaa", "aaa", "bbb", "bbb", "aaa", "ccc", "aaa", "bbb", "ccc")
> my %hash;
>
> foreach my $item (@array){
>     $hash{$item}++;
> }
>
> Tagore Smith

http://www.wetware.com/drieux/pbl/BenchMarks/uniqCounts.txt

ok, so my OCD is benchmarking - but I would like to offer
what I think may be a bit quicker - if speed is your Need...

   #------------------------
   #
   sub haveMap {
     my (@list) = @_;
     my %seen = ();

     map {$seen{$_}++} @list;

     \%seen ;

   } # end of haveMap


ciao
drieux

---


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to