Your code as presented is not building a HoH or indeed any single data structure at all from the CSV data. All it is doing is reading and printing it line by line. Replace your while loop with something like this (untested):
my %HoH; while (my $row = $csv->getline_hr($data)) { my $key = "$row->{latitude}.$row->{longitude}"; # Compare next if exists $HoH{$key} && $row->{id} <= $HoH{$key}->{id}; # Set (or overwrite) $HoH{$key} = { name => $row->{name}, id => $row->{id} }; } # At this point I would return the hash (or a reference to it) but you + would need to change the calling line, of course
See perldsc for more on such deep/nested structures.
🦛
In reply to Re^5: Update XML Values using two primary keys
by hippo
in thread Update XML Values using two primary keys
by pratikpooja
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |