use strict; use warnings; use Data::Dump; use List::Util qw( any ); my @choices = qw/Apple Banana Tiger Lion Cat Turtle/; my @Single = qw/Apple Turtle/; my @Double = qw/Apple Lion/; my %choices; for my $field (@choices) { my $flag = 0; $flag = 1 if any { $_ eq $field } @Single; $flag += 2 if any { $_ eq $field } @Double; $choices{$field} = $flag; } # $flag == 3 means $field is present in both @Single and @Double dd \%choices; #### 14:27 >perl 1508_SoPW.pl { Apple => 3, Banana => 0, Cat => 0, Lion => 2, Tiger => 0, Turtle => 1 } 14:28 >