The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

smartmatch - pluggable smart matching backends

VERSION

version 0.05

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

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 (~~). 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.

This module is lexically scoped, and you can call no smartmatch to restore the core perl smart matching behavior.

FUNCTIONS

callback_at_level($level)

Returns a coderef which will call smartmatching on its two arguments, with the smartmatch implementation used at caller level $level.

BUGS

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.

SEE ALSO

"Smart matching in detail" in perlsyn

smartmatch::engine::core

SUPPORT

You can find this documentation for this module with the perldoc command.

    perldoc smartmatch

You can also look for information at:

AUTHOR

Jesse Luehrs <doy at tozt dot net>

COPYRIGHT AND LICENSE

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.