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.
Junction - Perl6 style Junction operators in Perl5.
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) {
...
}
Inspired by the Perl6 design docs, SEE ALSO.
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;
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.
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.
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.
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.
None.
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).
Submit to the CPAN bugtracker http://rt.cpan.org
http://dev.perl.org/perl6/doc/design/exe/E06.html - ``The Wonderful World of Junctions''.
Carl Franks
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).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: RFC: Junction.pm
by dragonchild (Archbishop) on May 02, 2005 at 13:37 UTC | |
by hardburn (Abbot) on May 02, 2005 at 13:47 UTC | |
by itub (Priest) on May 02, 2005 at 15:20 UTC | |
by fireartist (Chaplain) on May 02, 2005 at 13:53 UTC | |
|
Re: RFC: Junction.pm
by Tanktalus (Canon) on May 02, 2005 at 14:40 UTC | |
by fireartist (Chaplain) on May 02, 2005 at 15:01 UTC | |
by fireartist (Chaplain) on May 03, 2005 at 17:03 UTC | |
|
Re: RFC: Junction.pm
by fireartist (Chaplain) on May 02, 2005 at 20:44 UTC | |
by eric256 (Parson) on May 02, 2005 at 21:05 UTC | |
by fireartist (Chaplain) on May 03, 2005 at 17:09 UTC | |
by eric256 (Parson) on May 03, 2005 at 20:19 UTC | |
by fireartist (Chaplain) on May 04, 2005 at 09:01 UTC | |
| |
by dragonchild (Archbishop) on May 03, 2005 at 17:27 UTC | |
|
Re: RFC: Junction.pm
by eric256 (Parson) on May 02, 2005 at 15:54 UTC |