in reply to Remove duplicated data from array ref
I'm not sure what your data is actually supposed to be (your declaration for $data is not valid perl, is this supposed to be an array of strings?) but there's a simple way to get unique elements in perl: hash keys.
You should avoid removing elements from an array while iterating over it, so outputing to another variable is probably better.my %uniq; my @data = qw(3328B0Z 3328B0Z 1122222 8888888T 3328B0Z 1122222 8888888 +T); $uniq{$_}++ for @data; my @uniq_data = keys %uniq
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Remove duplicated data from array ref
by Anonymous Monk on Nov 14, 2016 at 15:08 UTC | |
by haukex (Archbishop) on Nov 14, 2016 at 15:18 UTC |