It isn't clear whether you are starting with Perl arrays or simple comma-separated strings. I am also unsure whether you want the resultant hash values capitalised as you show, or the same as the input values.
This short program will do what you need. It simply assigns hash elements using each key from @a1
and an initial value of yes
. Thereafter, if a corresponding no
is encountered in @a2
then the element's value is set to no
.
use strict;
use warnings;
my @a1 = qw{ NET1020 NET0190 NET1020 NET0230 NET1020 NET1639 NET0820 NET1639 };
my @a2 = qw{ yes yes no no yes no yes no };
my %data;
for my $i (0 .. $#a1) {
my $key = $a1[$i];
$data{$key} = 'yes' unless $data{$key};
$data{$key} = 'no' if $a2[$i] eq 'no';
}
use Data::Dump;
dd \%data;
output
{
NET0190 => "yes",
NET0230 => "no",
NET0820 => "yes",
NET1020 => "no",
NET1639 => "no",
}