Junction::Quotelike - quotelike junction operators


This document describes version 0.01 of Junction::Quotelike, released Sun Feb 14 16:20:27 CET 2010 @680 /Internet Time/


  use Junction::Quotelike qw/qany/;
  my $x = 'foo';
  print "is foo!" if $x eq qany/foo bar baz/; #is foo 


Junction::Quotelike glues Perl6::Junction and PerlX::QuoteOperator together to provide quotelike junction operators.


Junction::Quotelike defines the following Operators


Quotelike version of any(). Returns a junction that tests against one more of its Elements. See <Perl6::Junction> for details


Quotelike version of all(). Returns a junction that tests against all of its Elements. See <Perl6::Junction> for details


Quotelike version of one(). Returns a junction that tests against one (and only one) of its Elements. See <Perl6::Junction> for details


Quotelike version of none(). Returns a junction that tests against none of its Elements. See <Perl6::Junction> for details


Junction::Quotelike exports qany qall qnone qone upon request. You can import one or more of them in the usual way.

  use Junction::Quotelike qw'qall';


  use Junction::Quotelike qw'qany qall';

Altnernativly you can rename them while importing:

  use Junction::Quotelike { qany => 'any', qall => 'all' };

This would export the operators qany and qall to your namespace renamed to any and all, so you can write:

  my $anyjunction = any /foo bar baz/;
  my $alljunction = all /foo bar baz/;

You must however import at least one operator into your namespace.


"bad import spec: %s"

You requested an invalid operator to be exported. Currently valid operators are: qany|qall|qone|qnone.

"no import spec"

You didn't request any operator to be exported. Without exports this module is useless.


There are undoubtedly serious bugs lurking somewhere. If you believe you have found a new, undocumented or ill documented bug, then please drop me a mail to .


The list of supported delimiters is a bit more restricted than with standard quotelike operators. Currently tested and supported are:

  '/', '\', '!'

On the other hand known <not> to work are

  ''', '#'. '()', '[]', '{}'

In general, all bracketing delimiters are known not to work, and other non bracketing delimiters may work or not, but aren't tested (yet). These are restrictions from PerlX::QuoteOperator. With all these limitations this module may better be called Junction::Quotelikelike.


Junction::Quotelike relies on the dark magic performed by PerlX::QuoteOperator which enables custom quotelike operators. While this seems to work very stable, you should be aware that there may be some unexpected side effects. See PerlX::QuoteOperator for details.

It is not possible to use the operators directly witout importing them. Qualifying them like Junction::Quotelike::qany/foo bar/ <won't work>. I don't think that's bug since using qualified names would make the use of this module rather pointless.


Junction::Quotelike doesn't really do much on itself but rather relies on the services of these Modules to perform its job.


Perl6::Junction defines the semantics for junctions used by this module. If you're intrested in junctions without quotelike behavior this your friend.


PerlX::QuoteOperator enables the definition of custom quotelike operators in a straightforward manner.


Why not?

As of this writing i am working on some slightly complex piece of code that makes heavy use of junctions (as provided by Perl6::Junction). While this makes my code way less complex i'm still forced to write a lot lines like

  $valid = any(qw/this that something else/);

Sure that's not that bad, but it doesn't look nice to me. Writing it like:

  $valid = qany /this that something else/;

Looks a lot better to me.


  blackhat.blade (formerly Lionel Mehl) <>


         Copyright (c) 2010 blackhat.blade,
       This module is free software. It may be used, redistributed
           and/or modified under the terms of the Artistic license.