From d956ea977290fb71f494b015ea905f6dd1d407e2 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 8 Jul 2011 23:34:54 -0500 Subject: docs --- lib/smartmatch.pm | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/lib/smartmatch.pm b/lib/smartmatch.pm index 071e4ea..c7b67f6 100644 --- a/lib/smartmatch.pm +++ b/lib/smartmatch.pm @@ -18,6 +18,39 @@ __PACKAGE__->bootstrap( ? ${ $smartmatch::{VERSION} } : (), ); +=head1 SYNOPSIS + + 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 + +=head1 DESCRIPTION + +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 +(C<~~>). C 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 C prepended to it +and used as the name of a package in which to find a subroutine named C. +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. + +This module is lexically scoped, and you can call C to restore +the core perl smart matching behavior. + +=cut + sub import { my $package = shift; my ($cb) = @_; @@ -36,4 +69,57 @@ sub unimport { smartmatch::unregister(); } +=head1 BUGS + +No known bugs. + +Please report any bugs through RT: email +C, or browse to +L. + +=head1 SEE ALSO + +L + +L + +=head1 SUPPORT + +You can find this documentation for this module with the perldoc command. + + perldoc smartmatch + +You can also look for information at: + +=over 4 + +=item * AnnoCPAN: Annotated CPAN documentation + +L + +=item * CPAN Ratings + +L + +=item * RT: CPAN's request tracker + +L + +=item * Search CPAN + +L + +=back + +=begin Pod::Coverage + +import +unimport +register +unregister + +=end Pod::Coverage + +=cut + 1; -- cgit v1.2.3-54-g00ecf