Copied below is the docs from a module I've written: Junction.pm

It's inspired by the Junctions described in Perl6.

I'd appreciate any comments, including suitability of the module name, and whether it's lacking any features you think necessary, for the module to be useful.

NAME

Junction - Perl6 style Junction operators in Perl5.


SYNOPSIS

  my $j = Junction->new;
  
  if ($j->any(@grant) eq 'su') {
    ...
  }
  
  if ($j->all($foo, $bar) >= 10) {
    ...
  }
  
  if ($j->none(@pass) eq 'password') {
    ...
  }
  
  if ($j->one(@answer) == 42) {
    ...
  }
  
  # All methods can also be called on the Class Name
  
  if (Junction->one(@answer) == 42) {
    ...
  }


DESCRIPTION

Inspired by the Perl6 design docs, SEE ALSO.


METHODS

new()

Returns a stateless Junction object, on which you can call any of the methods listed below.

  my $j = Junction->new;
  
  $j->any;
  $j->all;

... which is provided as a short cut to typing:

  Junction->any;
  Junction->all;

all()

Returns an object which overloads the following operators:

  "<",  "<=", ">",  ">=", "==", "!=", 
  "lt", "le", "gt", "ge", "eq", "ne",

Returns true only if all arguments test true according to the operator used.

any()

Returns an object which overloads the following operators:

  "<",  "<=", ">",  ">=", "==", "!=", 
  "lt", "le", "gt", "ge", "eq", "ne",

Returns true if any argument tests true according to the operator used.

none()

Returns an object which overloads the following operators:

  "<",  "<=", ">",  ">=", "==", "!=", 
  "lt", "le", "gt", "ge", "eq", "ne",

Returns true only if no argument tests true according to the operator used.

one()

Returns an object which overloads the following operators:

  "<",  "<=", ">",  ">=", "==", "!=", 
  "lt", "le", "gt", "ge", "eq", "ne",

Returns true only if one and only one argument tests true according to the operator used.


EXPORT

None.


TO DO

Maybe allow the first argument to be a regex object, such that:

  $j->all( qr/\d+/, @input )

... matches all following arguments against the regex. Would need to figure out what to return and how/whether to handle captured values. (Suggestions welcome).


SUPPORT / BUGS

Submit to the CPAN bugtracker http://rt.cpan.org


SEE ALSO

http://dev.perl.org/perl6/doc/design/exe/E06.html - ``The Wonderful World of Junctions''.


AUTHOR

Carl Franks


COPYRIGHT AND LICENSE

Copyright 2005, Carl Franks. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself (perlgpl, perlartistic).


In reply to RFC: Junction.pm by fireartist

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.