S
Sherm Pendley
I have an array
@myarray = (2, 3, 5, 4, 3, 6, 3, 2, 1,0);
I want to separate the duplicate entries
perldoc -q duplicate
How can I remove duplicate elements from a list or array?
sherm--
I have an array
@myarray = (2, 3, 5, 4, 3, 6, 3, 2, 1,0);
I want to separate the duplicate entries
I have an array
@myarray = (2, 3, 5, 4, 3, 6, 3, 2, 1,0);
I want to separate the duplicate entries and put in a list and put all
the unique in other list.
list 1 contains (2,2,3,3,3)
list 2 contains (5,4,6,1,0).
I have an array
@myarray = (2, 3, 5, 4, 3, 6, 3, 2, 1,0);
I want to separate the duplicate entries and put in a list and put all
the unique in other list.
list 1 contains (2,2,3,3,3)
list 2 contains (5,4,6,1,0).
I have an array
@myarray = (2, 3, 5, 4, 3, 6, 3, 2, 1,0);
I want to separate the duplicate entries and put in a list and put
all the unique in other list.
list 1 contains (2,2,3,3,3)
list 2 contains (5,4,6,1,0).
my %saw;
$saw{$_}++ for @myarray;
my @duplicates =
map { $saw{ $myarray[$_] } > 1 ? splice @myarray, $_, 1 : () }
reverse 0..$#myarray;
A. Sinan Unur said:Gunnar said:[email protected] said:I have an array
@myarray = (2, 3, 5, 4, 3, 6, 3, 2, 1,0);
I want to separate the duplicate entries and put in a list and put
all the unique in other list.
list 1 contains (2,2,3,3,3)
list 2 contains (5,4,6,1,0).
my %saw;
$saw{$_}++ for @myarray;
my @duplicates =
map { $saw{ $myarray[$_] } > 1 ? splice @myarray, $_, 1 : () }
reverse 0..$#myarray;
I am not sure splice and reverse are necessary here
my @unique = grep { $saw{$_} == 1 } @myarray;
my @duplicates = grep { $saw{$_} > 1 } @myarray;
* [email protected] said:I have an array
@myarray = (2, 3, 5, 4, 3, 6, 3, 2, 1,0);
I want to separate the duplicate entries and put in a list and put all
the unique in other list.
list 1 contains (2,2,3,3,3)
list 2 contains (5,4,6,1,0).
A. Sinan Unur wrote:
....
....
What?? Thought you liked reverse(). ;-)
A. Sinan Unur said:I have an array
@myarray = (2, 3, 5, 4, 3, 6, 3, 2, 1,0);
I want to separate the duplicate entries and put in a list and put
all the unique in other list.
list 1 contains (2,2,3,3,3)
list 2 contains (5,4,6,1,0).
my %saw;
$saw{$_}++ for @myarray;
my @duplicates =
map { $saw{ $myarray[$_] } > 1 ? splice @myarray, $_, 1 : () }
reverse 0..$#myarray;
I am not sure splice and reverse are necessary here
#!/usr/bin/perl
use strict;
use warnings;
my @myarray = (2, 3, 5, 4, 3, 6, 3, 2, 1,0);
my %saw;
$saw{$_}++ for @myarray;
my @unique = grep { $saw{$_} == 1 } @myarray;
my @duplicates = grep { $saw{$_} > 1 } @myarray;
A. Sinan Unur said:You don't understand, I am very possesive
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.