I have this code to take rows and place them into %data. One row in DATA (last row) is a duplicate so I don’t want it to be added to %data. How do I check of the app_id and ci_name combination doesn’t already exist before pushing the row into %data? Something like
push .. unless {app_id already exists}
The code to modify:
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my %data;
while( <DATA> ) {
chomp;
next if /app_id/;
my ($app_id,$ci_name,$app_name) = split /,/;
push @{$data{$ci_name}}, {app_id => $app_id, app_name => $app_name };
}
print Dumper(\%data);
__DATA__
app_id,ci_name,app_name
1234,hosta7,Managed File Transfer
1235,hosta7,Patrtol
1236,hosta7,RELATIONAL DATA WAREHOUSE
1237,hosta7,Managed File Transfer
1238,hosta7,Initio Application
1239,hosta7,Data Warehouse Operations Infrastructure
2345,hostb,Tableou
2345,hostb,Tableou