Syntax...rtmatch(3pm)

πŸ“¦
version 0.011 Β· 2 versions
, in debian trixie, ubuntu resolute

πŸ’– Syntax::Infix::Smartmatch πŸ’–

okay bestie, welcome to the Syntax...rtmatch(3pm) page β€” yes that's the real title, the man page truncates it like it's embarrassed, but we're not πŸ’… this is User Contributed Perl Documentation and we're about to have a whole moment.


✨ NAME ✨

Syntax::Infix::Smartmatch β€” Smartmatch done right πŸŽ€


🌸 VERSION 🌸

version 0.011


πŸ¦‹ SYNOPSIS πŸ¦‹

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

like. look at it. one line. no chaos. slay ✨


πŸ‘‘ DESCRIPTION πŸ‘‘

NOTE: this module is currently still experimental, bestie, and the details of its behavior may still change. do not build your whole personality on it yet, fr fr 😭

so here's the tea πŸ“: this module implements a new, much simplified version of smartmatch. the big iconic glow-up? the behavior only depends on the right side argument. that's it. that's the whole vibe. the left side is just out here living its life, not influencing anything.

here's exactly what it does, based on whatever the right side argument is:

  • undef β€” returns "not defined $left". that's it, that's the whole check 🫢
  • object β€” if the object has smartmatch overloading (heads up: this might disappear in a future Perl version, so don't get too attached πŸ‘€), that gets called. otherwise it returns object identity.
  • regex β€” this is equivalent to "$left =~ $right". matching. iconic. no notes πŸ’…
  • sub β€” it returns the value of $right->($left). you hand it a coderef, it calls it with $left, done ✨
  • array β€” returns true if $left smartmatches any of the members of @$right. one of them hits, you win 🌈
  • other β€” returns "$left equ $right", which (for the record, since people always ask) means "defined $left and $left eq $right" πŸ‘‘

🧚 AUTHOR 🧚

Leon Timmermans <leont@cpan.org> β€” king behavior, honestly πŸ‘‘


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. periodt πŸ’…


and that's the whole page, bestie πŸŽ€ this was Syntax...rtmatch(3pm) from the User Contributed Perl Documentation, shipped with perl v5.40.1, dated 2025-04-19. go forth and smartmatch responsibly πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from