Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks!
I need to get rid of the duplicates coming from an array, as a sample here is some data:
Is there a better or correct way of doing this?
Thanks for looking!
I need to get rid of the duplicates coming from an array, as a sample here is some data:
$VAR1 = { 'ID' => '11', 'Name' => 'Mary', 'CC' => 'X5667' }; $VAR2 = { 'ID' => '10', 'Name' => 'Joe', 'CC' => 'X456' }; $VAR3 = { 'ID' => 'X2', 'Name' => 'Carl', 'CC' => 'P45' }; $VAR4 = { 'ID' => '12', 'Name' => 'Jim', 'CC' => 'PK1' ; $VAR5 = { 'ID' => '11', 'Name' => 'Mary', 'CC' => 'X5667' };
Is there a better or correct way of doing this?
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; foreach my $st ( @{ $stuff } ) { next if $st->{ID}; next if $st->{Name}; next if $st->{CC}; print $st->{ID} - $st->{Name} - $st->{CC}; }
Thanks for looking!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Duplicated data in array.
by LanX (Saint) on Nov 02, 2021 at 19:31 UTC | |
by Bod (Parson) on Nov 03, 2021 at 00:21 UTC | |
by Fletch (Bishop) on Nov 03, 2021 at 14:50 UTC | |
by soonix (Canon) on Nov 04, 2021 at 08:38 UTC | |
by Fletch (Bishop) on Nov 04, 2021 at 14:09 UTC | |
| |
by Anonymous Monk on Nov 02, 2021 at 20:11 UTC | |
by AnomalousMonk (Archbishop) on Nov 02, 2021 at 20:27 UTC | |
by LanX (Saint) on Nov 02, 2021 at 20:35 UTC | |
Re: Duplicated data in array.
by hippo (Bishop) on Nov 02, 2021 at 22:12 UTC | |
Re: Duplicated data in array.
by Anonymous Monk on Nov 02, 2021 at 19:07 UTC |
Back to
Seekers of Perl Wisdom