smartmatch - pluggable smart matching backends
version 0.05
1 ~~ 2; # false { use smartmatch sub { 1 }; 1 ~~ 2; # true no smartmatch; 1 ~~ 2; # false use smartmatch 'custom'; 1 ~~ 2; # smartmatch::engine::custom::match(1, 2) } 1 ~~ 2; # false
NOTE: This module is still experimental, and the API may change at any point. You have been warned!
This module allows you to override the behavior of the smart match operator (~~). use smartmatch $matcher hooks into the compiler to replace the smartmatch opcode with a call to a custom subroutine, specified either as a coderef or as a string, which will have smartmatch::engine:: prepended to it and used as the name of a package in which to find a subroutine named match. The subroutine will be called with two arguments, the values on the left and right sides of the smart match operator, and should return the result.
~~
use smartmatch $matcher
smartmatch::engine::
match
This module is lexically scoped, and you can call no smartmatch to restore the core perl smart matching behavior.
no smartmatch
Returns a coderef which will call smartmatching on its two arguments, with the smartmatch implementation used at caller level $level.
$level
No known bugs.
Please report any bugs through RT: email bug-smartmatch at rt.cpan.org, or browse to http://rt.cpan.org/NoAuth/ReportBug.html?Queue=smartmatch.
bug-smartmatch at rt.cpan.org
"Smart matching in detail" in perlsyn
smartmatch::engine::core
You can find this documentation for this module with the perldoc command.
perldoc smartmatch
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/smartmatch
CPAN Ratings
http://cpanratings.perl.org/d/smartmatch
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=smartmatch
Search CPAN
http://search.cpan.org/dist/smartmatch
Jesse Luehrs <doy at tozt dot net>
This software is copyright (c) 2012 by Jesse Luehrs.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install smartmatch, copy and paste the appropriate command in to your terminal.
cpanm
cpanm smartmatch
CPAN shell
perl -MCPAN -e shell install smartmatch
For more information on module installation, please visit the detailed CPAN module installation guide.