Re: remove duplicate values from array

2002-04-22 Thread drieux
On Monday, April 22, 2002, at 11:53 , Nikola Janceski wrote: > > Gosh.. what ever happened to good ol' grep > > my %seen; > @uniq = grep !$seen{$_}++, @array; http://www.wetware.com/drieux/CS/lang/Perl/Beginners/BenchMarks/ will show you that this works just slightly slower than just the has

Re: remove duplicate values from array

2002-04-22 Thread drieux
On Monday, April 22, 2002, at 03:43 , Alfred Vahau wrote: > Assuming that the array has been converted to a scalar, then the > following "Lookaround Assertion" works: > > #!/usr/bin/perl > > $_ = 'a a a b b c c'; > > 1 while s/\b(\w+) \s (?= \1\b ) //gxi; > print $_, "\n"; Survey Says: Benchma

Re: remove duplicate values from array

2002-04-22 Thread Alfred Vahau
Assuming that the array has been converted to a scalar, then the following "Lookaround Assertion" works: #!/usr/bin/perl $_ = 'a a a b b c c'; 1 while s/\b(\w+) \s (?= \1\b ) //gxi; print $_, "\n"; The scalar can be reconverted to an array. Not sure if this is any faster. Alfred, Project Bree

Re: remove duplicate values from array

2002-04-22 Thread José Nyimi
Ok, thanks ! I read it and every thing becomes clear to me :-) José. Jenda Krynicky <[EMAIL PROTECTED]> a écrit : From: José Nyimi > this slice thing is really very nice. > > @hash{@array1}=@array2; > > I saw it many times used in constructor of "Object Oriented" Perl's > code. > > Could you

Re: remove duplicate values from array

2002-04-22 Thread Jenda Krynicky
From: José Nyimi <[EMAIL PROTECTED]> > this slice thing is really very nice. > > @hash{@array1}=@array2; > > I saw it many times used in constructor of "Object Oriented" Perl's > code. > > Could you explain sequencely the syntax please ? Well I don't think I can make up a better explanation than

RE: remove duplicate values from array

2002-04-22 Thread Nikola Janceski
Gosh.. what ever happened to good ol' grep my %seen; @uniq = grep !$seen{$_}++, @array; > -Original Message- > From: Jon Howe [mailto:[EMAIL PROTECTED]] > Sent: Monday, April 22, 2002 12:30 PM > To: [EMAIL PROTECTED] > Subject: remove duplicate values from array >

Re: remove duplicate values from array

2002-04-22 Thread José Nyimi
Hé ! Jenda this slice thing is really very nice. @hash{@array1}=@array2; I saw it many times used in constructor of "Object Oriented" Perl's code. Could you explain sequencely the syntax please ? José. - Yahoo! Mail -- Une adresse @yahoo.fr gratuite et en f

Re: remove duplicate values from array

2002-04-22 Thread Jenda Krynicky
From: drieux <[EMAIL PROTECTED]> > On Monday, April 22, 2002, at 09:29 , David Gray wrote: > > >> Can anyone tell me the best method for removing duplicate > >> array values. > >> > >> eg: > >> > >> @array = qw( a a a b b b c); > >> > >> becomes after some operation I cant seem to figure: > >> >

Re: remove duplicate values from array

2002-04-22 Thread drieux
On Monday, April 22, 2002, at 09:29 , David Gray wrote: >> Can anyone tell me the best method for removing duplicate >> array values. >> >> eg: >> >> @array = qw( a a a b b b c); >> >> becomes after some operation I cant seem to figure: >> >> @new_array_or_same = (a b c); > > In this situation,

Re: remove duplicate values from array

2002-04-22 Thread Miroslav Nikolov
i`m not quite shure because i`m a newbie to, but try using some RegExp like tr/// and dont forget that tr// and s// have many more functions ex. using the (?). The book that i find most explainable about RegExp is Beginning Perl from Wrox Publishing. - Cheers, Miroslav Nikol

RE: remove duplicate values from array

2002-04-22 Thread David Gray
> Can anyone tell me the best method for removing duplicate > array values. > > eg: > > @array = qw( a a a b b b c); > > becomes after some operation I cant seem to figure: > > @new_array_or_same = (a b c); In this situation, I usually use a hash instead of an array so I can create highly

Re: remove duplicate values from array

2002-04-22 Thread Jeff 'japhy' Pinyan
On Apr 22, Jon Howe said: >Can anyone tell me the best method for removing duplicate array values. I think the FAQ answers this best. perldoc -q uniq -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://

remove duplicate values from array

2002-04-22 Thread Jon Howe
Can anyone tell me the best method for removing duplicate array values. eg: @array = qw( a a a b b b c); becomes after some operation I cant seem to figure: @new_array_or_same = (a b c);