in reply to Removal of duplicated element in array.
Hi tty1x,
A few snapshot observations and 2 'kobo' suggestion:
- A number of solution previously given to you actually work, only that some may not preserve the order of data.
- This does work for me, which is not far from your OP, except that I have to create the variable $match.
use warnings; use strict; my $match = <<'EOF'; dddd@fgg.com cccc@fgg.com eeee@fgg.com dddd@fgg.com EOF my %seen; my @r; foreach my $v ( split /\n/, $match ) { unless ( $seen{$v}++ ) { push @r, $v; } } $" = "\n"; print "@r";
- Please, as much as possible try not to use the variable $a, since function sort uses it
If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me
In Section
Seekers of Perl Wisdom