# Find suits of any jack in the first 4 cards my %jack = map { $_ => 1 } substr($str, 0, 8) =~ /(?<=J)(.)/g; # Determine if the suit of the 5th card matches ++$score if $jack{ substr($str, -1, 1) };