Smartmatch (denoted by ~~) is a Perl operator that does "smart" comparisons of operands with possibly differing types (e.g. string and array).
Smartmatch (denoted by ~~
) is a Perl operator that does "smart" comparisons of operands with possibly differing types (e.g. string and array).
For example:
'foo' ~~ @array
returns true if @array
contains any elements equal to the string foo
.
Smartmatch was first introduced in Perl 5.10.0 and changed significantly in 5.10.1. As of Perl 5.18.0, smartmatch is experimental and will almost certainly change or be removed completely in a future release. Using it in its current form is discouraged.