use strict; use warnings; my @hand3 = qw/KsQs JsAs/; my @hand4 = qw/AsKc 2s3s/; my @hand899 = qw/As3c/; my @handsLists = (\@hand3, \@hand4, \@hand899); ##Set my hand my $my_pocket = "AcAs"; #My cards my %pocketCards = map {$_ => 0} $my_pocket =~ /(.{2})/g; printf join '', keys %pocketCards, "\n\n"; for my $hands (@handsLists) { # If either pocket card matches the first hand card omit the hand @$hands = grep {! exists $pocketCards{substr ($_, 0, 2)}} @$hands; print "@$hands\n"; } #### KsQs JsAs 2s3s #### KsQs 2s3s