RE: Down and dirty duplicate deleter

2002-07-30 Thread Nikola Janceski
mailto:[EMAIL PROTECTED]] > Sent: Tuesday, July 30, 2002 3:08 PM > To: 'Kirby_Sarah'; [EMAIL PROTECTED] > Subject: RE: Down and dirty duplicate deleter > > > { > my %seen; > @uniq = grep { !$seen{$_}++ }, @arrayWithDups; > } > > > -Original Message

Re: Down and dirty duplicate deleter

2002-07-30 Thread Jeff 'japhy' Pinyan
On Jul 30, Jeff 'japhy' Pinyan said: >On Jul 30, Kirby_Sarah said: > >>I have instances where I want to delete duplicate elements out of an array. >>Is there an easy way to do this? > >Yes, and the FAQ tells you: > > >http://www.perldoc.com/perl5.6.1/pod/perlfaq4.html#How-can-I-remove-duplicate

Re: Down and dirty duplicate deleter

2002-07-30 Thread Robin Norwood
Kirby_Sarah <[EMAIL PROTECTED]> writes: > Hi, > > I have instances where I want to delete duplicate elements out of an array. > Is there an easy way to do this? Sure, The Perl Cookbook provides several ways - here's one: (Recipe 4.6, page 102) my @list = qw/one two three one two five/; my @

RE: Down and dirty duplicate deleter

2002-07-30 Thread nkuipers
Load the elements of an array into a hash. Then put the unique keys back into the array; add other goodies like sorting if you need, but one barebones way of doing it would be: for (@array) { chomp $_; $hash{$_}++ } @array = (); @array = keys %hash; -- To unsubscribe, e-mail: [EMAIL PROTECT

RE: Down and dirty duplicate deleter

2002-07-30 Thread Jeff 'japhy' Pinyan
On Jul 30, Nikola Janceski said: >{ >my %seen; >@uniq = grep { !$seen{$_}++ }, @arrayWithDups; >} That comma will get you. Either grep BLOCK LIST or grep EXPR, LIST but never grep BLOCK, LIST -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia

RE: Down and dirty duplicate deleter

2002-07-30 Thread Timothy Johnson
One of the classic ways is to assign each element as a key of a hash. foreach(@array){ $hash{$_} = 1; } @array = keys %hash; -Original Message- From: Kirby_Sarah [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 30, 2002 12:04 PM To: [EMAIL PROTECTED] Subject: Down and dirty duplicate

Re: Down and dirty duplicate deleter

2002-07-30 Thread Jeff 'japhy' Pinyan
On Jul 30, Kirby_Sarah said: >I have instances where I want to delete duplicate elements out of an array. >Is there an easy way to do this? Yes, and the FAQ tells you: perldoc -q duplicate or perldoc -q unique depending on which version of Perl you've got. (Newer versions have it under

RE: Down and dirty duplicate deleter

2002-07-30 Thread Shishir K. Singh
>Hi, >I have instances where I want to delete duplicate elements out of an array. >Is there an easy way to do this? Well, if the order of the elements in the array does not matter, then you may try putting he array elements in a hash ++$uniq{$_} for (@array); then convert it back to array;

RE: Down and dirty duplicate deleter

2002-07-30 Thread Nikola Janceski
{ my %seen; @uniq = grep { !$seen{$_}++ }, @arrayWithDups; } > -Original Message- > From: Kirby_Sarah [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, July 30, 2002 3:04 PM > To: [EMAIL PROTECTED] > Subject: Down and dirty duplicate deleter > > > Hi, > > I

Down and dirty duplicate deleter

2002-07-30 Thread Kirby_Sarah
Hi, I have instances where I want to delete duplicate elements out of an array. Is there an easy way to do this? -Sarah -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]