in reply to Count of words that match in an array
my @Array1 = qw( A B C D );
my @Array2 = qw( J C T A );
for ( @Array1 )
$count++ if $_ ~~ @Array2;
print "Count = $count\n";
It should be noted that '~~', the Smartmatch Operator, is experimental: see "perl5180delta: The smartmatch family of features are now experimental".
I haven't investigated whether it makes a difference with this specific usage; however, it may be worth checking this (from "perlop: Smartmatch Operator"):
"First available in Perl 5.10.1 (the 5.10.0 version behaved differently), ..."
www.com | www.net | www.org
No recent polls found