foreach my $name (sort keys %file2) { my $ip1 = $file2{$name}; if ( not exists $file1{$name} ){ # check if ip exists if ($description=null){ my $id = $ip2name{$ip1}; print "DELETE name : '$name'\n"; push @delete,[$id,$name,$description,$ip] } }