On Tue, 7 Jan 2003 [EMAIL PROTECTED] wrote:

> I need to be able to generate a unique list from a list that could
> possibly have duplicate entries in it.  Has anyone developed an easy way
> to do that?
>

The most straignt forward way is to create a hash slice from the
list by using the list elements as the hash keys and then use
keys %hash (or sort keys %hash) to get a "unique" list.

@hash{@list}=((1) x @list); #create the hash via a hash slice

@list=keys %hash; # get the unique keys in "random" order

 OR

@list=sort keys %hash; #if you want the list sorted

If you want or need to, you can create a unique list that
preserves the original order of the list and just eliminates
the duplicates but that is left as an excercise for the reader.

**** [EMAIL PROTECTED] <Carl Jolley>
**** All opinions are my own and not necessarily those of my employer ****

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to