in reply to Can't remove the the duplicate element when it's the last one in the array
Take a look at the uniq() function ...
I second that.
Your code seems to be too "tricky" ...
Too tricky by half. But if you are going to recommend 'simple' code, at least recommend the idiomatic version:
>perl -wMstrict -le "my @ra = (1, 3, 2, 3, 2, 3, qw{X b X c X}); my %seen; @ra = grep !$seen{$_}++, @ra; print qq{@ra}; " 1 3 2 X b c
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Can't remove the the duplicate element when it's the last one in the array
by johngg (Canon) on Dec 18, 2009 at 19:32 UTC | |
by littlehorse (Sexton) on Dec 20, 2009 at 07:46 UTC | |
|
Re^2: Can't remove the the duplicate element when it's the last one in the array
by littlehorse (Sexton) on Dec 20, 2009 at 07:43 UTC |