use strict; use warnings; use List::Util qw( any ); my @input_array = qw( N1 N2 N3 N6 N7 ); my @input_A = qw( N1 N3 N11 N11 N10 N16 ); my @input_B = qw( N3 N6 N2 N7 N16 N19 ); my %primaryCC0; for my $inputKey (@input_array) { if (any { $_ eq $inputKey } @input_A) { if (any { $_ eq $inputKey } @input_B) { @{ $primaryCC0{$inputKey} } = (1, 1); } else { print "$inputKey: only 1 input is PI\n"; } } else { print "$inputKey: this is a wire\n"; } } for my $key (sort keys %primaryCC0) { my ($CC0, $CC1) = @{ $primaryCC0{$key} }; print "CC0[$key] = $CC0\n"; print "CC1[$key] = $CC1\n"; }