Syntax::Infix::Smartmatch3pm
Smartmatch done right
Usage
say "YES" if $value ~~ [1, 2, qr/42/];
Version
version 0.011
Overview
NOTE: This module is currently still experimental and the details of its behavior may still change.
This module implements a new, much simplified version of smartmatch. In particular the behavior only depends on the right side argument. In particular it will do the following based on the right side argument:
- •
-
undef
This will return
"not defined $left".
- •
-
object
If the object has smartmatch overloading (note: this might disappear in a future Perl version), that is called. Otherwise it returns object identity.
- •
-
regex
This is equivalent to
"$left =~ $right".
- •
-
sub
It will return the value of
$right->($left)
- •
-
array
This will return true if
$leftsmartmatches any of the members of@$right.
- •
-
other
This will return
"$left equ $right"("defined $left and $left eq $right").
Copyright and license
This software is copyright (c) 2023 by Leon Timmermans.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.