|o||If the right hand side is undef, then there is only a match if the left hand side is also undef.|
|o||If the right hand side is a non-reference, then the match is a simple string match.|
|o||If the right hand side is a reference to a regexp, then the left hand is evaluated .|
|o||If the right hand side is a code reference, then it is called in a boolean context with the left hand side being passed as an argument.|
|o||If the right hand side is an object which provides a MATCH method, then it this is called as a method, with the left hand side being passed as an argument.|
|o||If the right hand side is an object which overloads ~~, then a true smart match is performed.|
|o||If the right hand side is an arrayref, then the operator recurses into the array, with the match succeeding if the left hand side matches any array element.|
|o||If any other value appears on the right hand side, the operator will croak.|
use match::simple qw(match);
if (match($this, $that))
say "$this matches $that";
If youre making heavy use of this module, then this is probably your best option, as it runs significantly faster.
If you install match::simple::XS, a faster XS-based implementation will be used instead of the pure Perl functions. Depending on what sort of match you are doing, this is likely to be several times faster. In extreme cases, such as matching a string in an arrayref, it can be twenty-five times faster, or more. However, where $that is a single regexp, its around 30% slower. Overall though, I think the performance improvement is worthwhile.
If you want to take advantage of this speed up, use the match function rather than the |M| operator. Otherwise all your gains will be lost to the slow implementation of operator overloading.
The constant match::simple::IMPLEMENTATION tells you which backend is currently in use.
Setting the MATCH_SIMPLE_IMPLEMENTATION environment variable to PP encourages match::simple to use the pure Perl backend.
Please report any bugs to <http://rt.cpan.org/Dist/Display.html?Queue=match-simple>.
This module uses Exporter::Tiny.
Toby Inkster <firstname.lastname@example.org>.
This software is copyright (c) 2013-2014 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
THIS PACKAGE IS PROVIDED AS IS AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|perl v5.20.3||MATCH::SIMPLE (3)||2014-07-02|