szabgab has asked for the wisdom of the Perl Monks concerning the following question:

I am not sure it should be but I just found that
42 ~~ [23, 17, "42x", 70]
will give you a warning
Argument "42x" isn't numeric in smart match
It is the described behavior as this is Num ~~ Array case but I wonder why it is doing == and not smart matching on each individual element of the Array?

Update

Since then I had another issue with smart matching: "42" ~~ "42.0" is false in 5.10 and I have written a few blog entries too about Smart Matching and Switching in Perl 5.10. If someone is interested...

Replies are listed 'Best First'.
Re: Smart Match is not recursive in 5.10
by polettix (Vicar) on Dec 22, 2007 at 12:33 UTC
    While I don't know why (efficiency, I presume, or simplicity, or simply nobody tought about it, or whatever), I was thinking that recursively applying the smart match on each individual element would allow smart-matching over a "complicated" data structure, like a matrix. Something like:
    42 ~~ [ [ 0 .. 9 ], [ 20 .. 29 ], [ 40 .. 49 ], ]
    I'm still wondering if this could be named a feature or a bug, anyway :D

    Hey! Up to Dec 16, 2007 I was named frodo72, take note of the change! Flavio
    perl -ple'$_=reverse' <<<ti.xittelop@oivalf

    Io ho capito... ma tu che hai detto?
Re: Smart Match is not recursive in 5.10
by mikfire (Deacon) on Dec 24, 2007 at 14:38 UTC
    When did you build? How did you generate this error? I am trying it like this:
    perl -E 'say 42 ~~ [23,17,"42x",70]'
    and generating no error. It actually returns true, like I would expect.
      It's a warning, not an error. Try it with warnings enabled.