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
>>
>>
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
(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
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
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
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
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{$_}++/} @
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
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:
>
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.
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
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 =
>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
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
14 matches
Mail list logo