---
name: "Syntax::Infix::Smartmatch"
section: "3pm"
platform: "linux"
package: "libsyntax-infix-smartmatch-perl"
version: "0.011-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Syntax::Infix::Smartmatch"
---

# Syntax::Infix::Smartmatch(3pm)

Smartmatch done right

## NAME

Syntax::Infix::Smartmatch - Smartmatch done right

## VERSION

version 0.011

## SYNOPSIS

```
 say "YES" if $value ~~ [1, 2, qr/42/];
```

## DESCRIPTION

**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 `$left` smartmatches any of the members of `@$right`.

- •

  other

  This will return `"$left equ $right"` (`"defined $left and $left eq $right"`).

## AUTHOR

Leon Timmermans \<leont@cpan.org\>

## 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.
