/usr/share/doc/libmatch-simple-perl/README is in libmatch-simple-perl 0.009-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | NAME
match::simple - simplified clone of smartmatch operator
SYNOPSIS
use v5.10;
use match::simple;
if ($this |M| $that)
{
say "$this matches $that";
}
DESCRIPTION
match::simple provides a simple match operator `|M|` that acts like a sane
subset of the (as of Perl 5.18) deprecated smart match operator. Unlike
smart match, the behaviour of the match is determined entirely by the
operand on the right hand side.
* If the right hand side is `undef`, then there is only a match if the
left hand side is also `undef`.
* If the right hand side is a non-reference, then the match is a simple
string match.
* If the right hand side is a reference to a regexp, then the left hand
is evaluated .
* 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.
* 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.
* If the right hand side is an object which overloads `~~`, then a true
smart match is performed.
* 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.
* If any other value appears on the right hand side, the operator will
croak.
If you don't like the crazy Sub::Infix operator, you can alternatively
export a more normal function:
use v5.10;
use match::simple qw(match);
if (match($this, $that))
{
say "$this matches $that";
}
If you're making heavy use of this module, then this is probably your best
option, as it runs significantly faster.
XS Backend
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, it's
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.
Environment
Setting the `MATCH_SIMPLE_IMPLEMENTATION` environment variable to "PP"
encourages match::simple to use the pure Perl backend.
BUGS
Please report any bugs to
<http://rt.cpan.org/Dist/Display.html?Queue=match-simple>.
SEE ALSO
match::smart.
This module uses Exporter::Tiny.
AUTHOR
Toby Inkster <tobyink@cpan.org>.
COPYRIGHT AND LICENCE
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.
DISCLAIMER OF WARRANTIES
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.
|