On Apr 21, 2004, at 8:24 AM, Peterson, Darren - Contractor.Westar wrote:

I'd like to remove duplicate values from an array to leave it with only
unique values.  For instance, if an array contains (1,2,3,1,4,2,5) as
values, I'd like to clean out the extra 1 and 2 to leave the values as
(1,2,3,4,5).  Does perl have an array command to do that, or must the
process be purely manual?

You'll have to roll up the sleeves and code a solution. Something like:


my @array = (1, 2, 3, 1, 4, 2, 5);

my %seen;
foreach (@array) { $seen{$_}++; }
@array = keys %seen;

Hope that helps.

James


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to