In the following code, why does the first smartmatch fail to match and give the warning Argument "two" isn't numeric in smart match
, while the second smartmatch works as expected (it matches)?
use strict;
use warnings;
use feature 'say';
my %h = ("one" => "un", "two" => "deux");
my $v = "two";
my @keys_h = keys %h;
say "matches first form" if $v ~~ keys %h; # warning, doesn't match
say "matches second form" if $v ~~ @keys_h; # no warning, matches
I realize I could just use
$v ~~ %h
but I'd like to know why the first smartmatch doesn't work as I expect it to. I'm using Perl 5.10.1.