Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
… my @loop_names = (); foreach my $row (@{$names_data}) { my %row_data; $row_data{NAMES} = $row->{NAMES} || ''; push(@loop_names, \%row_data); } # Dumper of @loop_names; =code $VAR1 = { 'NAMES' => 'John Doe' }; $VAR2 = { 'NAMES' => 'Mary Lou' } =cut
my @loop_addr = (); foreach my $row (@{$all_party_id_data}) { my %row_data; $row_data{FULL_NAME} = $row->{FULL_NAME} || ''; $row_data{ADDR} = $row->{ADDR} || ''; $row_data{ZIP} = $row->{ZIP} || ''; warn Dumper $row_data{FULL_NAME}; # it will get "Mary Lou" # I just want @loop_names to have what is unique @loop_names = map /$row_data{FULL_NAME}/ ? () : $_, @loop_names; $row_data{N_DATA} = \@loop_names; push(@loop_addr, \%row_data); } # Dumper of @loop_addr =code $VAR1 = { 'FULL_NAME' => 'Mary Lou', 'ADDR' => '100 - Main Street', 'ZIP' => '12345', 'EMAIL_DATA' => [ { 'NAMES' => 'John Doe' }, { 'NAMES' => 'Mary Lou' # this shouldn't be here + } ], }; =cut
$VAR1 = { 'FULL_NAME' => 'Mary Lou', 'ADDR' => '100 - Main Street', 'ZIP' => '12345', 'EMAIL_DATA' => [ { 'NAMES' => 'John Doe' }, ], };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Get only unique values into array
by pme (Monsignor) on Jan 28, 2015 at 19:53 UTC | |
|
Re: Get only unique values into array
by stonecolddevin (Parson) on Jan 28, 2015 at 23:23 UTC | |
|
Re: Get only unique values into array
by Anonymous Monk on Jan 28, 2015 at 19:59 UTC | |
|
Re: Get only unique values into array
by BillKSmith (Monsignor) on Jan 28, 2015 at 23:55 UTC | |
|
Re: Get only unique values into array
by Laurent_R (Canon) on Jan 28, 2015 at 19:49 UTC | |
by Laurent_R (Canon) on Jan 28, 2015 at 20:01 UTC | |
|
Re: Get only unique values into array
by poj (Abbot) on Jan 28, 2015 at 19:53 UTC | |
by Anonymous Monk on Jan 28, 2015 at 20:05 UTC |