1smartmatch(3) User Contributed Perl Documentation smartmatch(3)
2
3
4
6 smartmatch - pluggable smart matching backends
7
9 version 0.05
10
12 1 ~~ 2; # false
13 {
14 use smartmatch sub { 1 };
15 1 ~~ 2; # true
16
17 no smartmatch;
18 1 ~~ 2; # false
19
20 use smartmatch 'custom';
21 1 ~~ 2; # smartmatch::engine::custom::match(1, 2)
22 }
23 1 ~~ 2; # false
24
26 NOTE: This module is still experimental, and the API may change at any
27 point. You have been warned!
28
29 This module allows you to override the behavior of the smart match
30 operator ("~~"). "use smartmatch $matcher" hooks into the compiler to
31 replace the smartmatch opcode with a call to a custom subroutine,
32 specified either as a coderef or as a string, which will have
33 "smartmatch::engine::" prepended to it and used as the name of a
34 package in which to find a subroutine named "match". The subroutine
35 will be called with two arguments, the values on the left and right
36 sides of the smart match operator, and should return the result.
37
38 This module is lexically scoped, and you can call "no smartmatch" to
39 restore the core perl smart matching behavior.
40
42 callback_at_level($level)
43 Returns a coderef which will call smartmatching on its two arguments,
44 with the smartmatch implementation used at caller level $level.
45
47 No known bugs.
48
49 Please report any bugs through RT: email "bug-smartmatch at
50 rt.cpan.org", or browse to
51 <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=smartmatch>.
52
54 "Smart matching in detail" in perlsyn
55
56 smartmatch::engine::core
57
59 You can find this documentation for this module with the perldoc
60 command.
61
62 perldoc smartmatch
63
64 You can also look for information at:
65
66 • AnnoCPAN: Annotated CPAN documentation
67
68 <http://annocpan.org/dist/smartmatch>
69
70 • CPAN Ratings
71
72 <http://cpanratings.perl.org/d/smartmatch>
73
74 • RT: CPAN's request tracker
75
76 <http://rt.cpan.org/NoAuth/Bugs.html?Dist=smartmatch>
77
78 • Search CPAN
79
80 <http://search.cpan.org/dist/smartmatch>
81
83 Jesse Luehrs <doy at tozt dot net>
84
86 This software is copyright (c) 2012 by Jesse Luehrs.
87
88 This is free software; you can redistribute it and/or modify it under
89 the same terms as the Perl 5 programming language system itself.
90
91
92
93perl v5.36.0 2023-01-20 smartmatch(3)