GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  MATCH::SMART (3)

.ds Aq ’

NAME

match::smart - clone of smartmatch operator

CONTENTS

SYNOPSIS



   use v5.10;
   use match::smart;
  
   if ($this |M| $that)
   {
      say "$this matches $that";
   }



DESCRIPTION

match::smart provides a match operator |M| that acts like more or less identically to the (as of Perl 5.18) deprecated smart match operator.

If you don’t like the crazy Sub::Infix operator, you can alternatively export a more normal function:



   use v5.10;
   use match::smart qw(match);
  
   if (match($this, $that))
   {
      say "$this matches $that";
   }



    Differences with ~~

There were major changes to smart match between 5.10.0 and 5.10.1. This module attempts to emulate the behaviour of the operator in more recent versions of Perl. In particular, 5.18.0 (minus the warnings). Divergences not noted below should be considered bugs.

While the real smart match operator implicitly takes references to operands that are hashes or arrays, match::smart’s operator does not.



   @foo ~~ %bar       # means: \@foo ~~ \%bar
   @foo |M| %bar      # means: scalar(@foo) |M| scalar(%bar)



If you want the \@foo ~~ \%bar behaviour, you need to add the backslashes yourself:



   \@foo |M| \%bar



Similarly:



   "foo" ~~  /foo/    # works
   "foo" |M| /foo/    # no worky!
   "foo" |M| qr/foo/  # do this instead



match::smart treats the MATCH method on blessed objects (if it exists) like an overloaded ~~. This is for compatibility with match::simple, and for compatibility with pre-5.10 Perls that don’t allow overloading ~~.

BUGS

Please report any bugs to <http://rt.cpan.org/Dist/Display.html?Queue=match-simple>.

SEE ALSO

match::simple.

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.
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 MATCH::SMART (3) 2014-07-02

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.