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!
Back to
Seekers of Perl Wisdom