develooper Front page | perl.beginners | Postings from April 2002

RE: Array question

Thread Previous | Thread Next
From:
Timothy Johnson
Date:
April 1, 2002 09:57
Subject:
RE: Array question
Message ID:
C0FD5BECE2F0C84EAA97D7300A500D5002581209@SMILEY

You could always put them into a hash and then put them into an array later.

foreach(@names){
   $hash{$_} = 1;
}

my @array = keys %hash;

-----Original Message-----
From: Allison Ogle [mailto:aogle@ti.com]
Sent: Monday, April 01, 2002 8:08 AM
To: a a
Subject: Array question


Hi,

I have a datafile with a list of names like

Ana
John
Mike
Tracy
John
Luke
...
etc.

I don't know how long the list is and eventually in the list some of the
names will repeat.  I want to put these names in an array but I don't want
to repeat any names in the array and I want to keep a count of how many
times the name appears in the list.  Does anyone have any ideas or
suggestions?  Thanks,

Allison


-- 
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org


--------------------------------------------------------------------------------
This email may contain confidential and privileged 
material for the sole use of the intended recipient. 
If you are not the intended recipient, please contact 
the sender and delete all copies.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About