Re: uniq elements of an array

2002-08-30 Thread Jeff 'japhy' Pinyan
On Aug 30, david said: >Ramprasad A Padmanabhan wrote: > >> Hi All, >>I have been using perl on linux for quiet some time now and I have >> found that Perl does not work the same in windows >> >>eg. To get all the unique elements of an array in linux I use a >> simple one liner >> >>

RE: uniq elements of an array

2002-08-30 Thread David . Wagner
PROTECTED]] Sent: Friday, August 30, 2002 12:07 To: Felix Geerinckx; [EMAIL PROTECTED] Subject: RE: uniq elements of an array Slice is simple and also faster ! Look: #!/usr/bin/perl use strict; use Benchmark; my @a=qw(a c b c a a b d c c); my @uniq=(); sub using_grep{ my %seen

RE: uniq elements of an array

2002-08-30 Thread NYIMI Jose (BMB)
(n=100) José. -Original Message- From: NYIMI Jose (BMB) Sent: Friday, August 30, 2002 9:07 PM To: Felix Geerinckx; [EMAIL PROTECTED] Subject: RE: uniq elements of an array Slice is simple and also faster ! Look: #!/usr/bin/perl use strict; use Benchmark; my @a=qw(a c b c a a b

RE: uniq elements of an array

2002-08-30 Thread NYIMI Jose (BMB)
ck secs (15.80 usr + 0.00 sys = 15.80 CPU) @ 63283.13/s (n=100) José. -Original Message- From: Felix Geerinckx [mailto:[EMAIL PROTECTED]] Sent: Friday, August 30, 2002 8:39 PM To: [EMAIL PROTECTED] Subject: Re: uniq elements of an array on Fri, 30 Aug 2002 18:26:03 GMT, Tom

Re: uniq elements of an array

2002-08-30 Thread Felix Geerinckx
on Fri, 30 Aug 2002 18:26:03 GMT, Tom Allison wrote: > david wrote: >> @hash{@all_elements} = (); >> >> now "keys %hash" gives you the unique elements. > > Would these exist but be undef? > > Why don't you write a little program to try it out, using the aptly named 'exists' and 'defined' fu

Re: uniq elements of an array

2002-08-30 Thread Tom Allison
david wrote: > Ramprasad A Padmanabhan wrote: > > >>Hi All, >> I have been using perl on linux for quiet some time now and I have >>found that Perl does not work the same in windows >> >> eg. To get all the unique elements of an array in linux I use a >>simple one liner >> >> @unique = gr

Re: uniq elements of an array

2002-08-30 Thread david
Ramprasad A Padmanabhan wrote: > Hi All, >I have been using perl on linux for quiet some time now and I have > found that Perl does not work the same in windows > >eg. To get all the unique elements of an array in linux I use a > simple one liner > >@unique = grep{!/$seen{$_}++/} @

Re: uniq elements of an array

2002-08-30 Thread Ramprasad A Padmanabhan
Dharmendra rai wrote: > have u seen the values in @unique when @all_elements contains (1,2,3,1,2) when u >apply @unique = grep { !$seen{$_}} @all_elements ??? > > its is not working > > > > > - > Get a bigger mailbox -- choose a size that fits your need

Re: uniq elements of an array

2002-08-30 Thread Sudarshan Raghavan
On 30 Aug 2002, Felix Geerinckx wrote: > on Fri, 30 Aug 2002 17:32:36 GMT, [EMAIL PROTECTED] (Sudarshan > Raghavan) wrote: > > > Why do you need to do a pattern match anyways? Just a > > @unique = grep{!$seen{$_}} @all_elements; > > should do > > You forgot to increment. The correct way is: >

Re: uniq elements of an array

2002-08-30 Thread Dharmendra Rai
have u seen the values in @unique when @all_elements contains (1,2,3,1,2) when u apply @unique = grep { !$seen{$_}} @all_elements ??? its is not working - Get a bigger mailbox -- choose a size that fits your needs.

Re: uniq elements of an array

2002-08-30 Thread Felix Geerinckx
on Fri, 30 Aug 2002 17:32:36 GMT, [EMAIL PROTECTED] (Sudarshan Raghavan) wrote: > Why do you need to do a pattern match anyways? Just a > @unique = grep{!$seen{$_}} @all_elements; > should do You forgot to increment. The correct way is: @unique = grep{!$seen{$_}++} @all_elements; -- feli

Re: uniq elements of an array

2002-08-29 Thread Sudarshan Raghavan
On Fri, 30 Aug 2002, Ramprasad A Padmanabhan wrote: > Hi All, >I have been using perl on linux for quiet some time now and I have > found that Perl does not work the same in windows > >eg. To get all the unique elements of an array in linux I use a > simple one liner > >@unique =

Re: uniq elements of an array

2002-08-29 Thread Omanakuttan
>eg. To get all the unique elements of an array in linux I use a > simple one liner > >@unique = grep{!/$seen{$_}++/} @all_elements; > The above expression did not work for me, I could not even found out how this should work. So I created a small file with... @all_elements = qw(hello al

uniq elements of an array

2002-08-29 Thread Ramprasad A Padmanabhan
Hi All, I have been using perl on linux for quiet some time now and I have found that Perl does not work the same in windows eg. To get all the unique elements of an array in linux I use a simple one liner @unique = grep{!/$seen{$_}++/} @all_elements; But this does not even pass sy