List::...ctions(3pm)
π List::...ctions(3pm) β List::Objects::WithUtils::Role::Array::WithJunctions
okay bestie, so this is a User Contributed Perl Documentation page, and the module in question is List::Objects::WithUtils::Role::Array::WithJunctions. the whole vibe? junctions, but for your arrays. β¨
πΈ NAME πΈ
List::Objects::WithUtils::Role::Array::WithJunctions β Add junctions π
like, it literally just adds junctions. that's the whole thing. iconic behaviour honestly.
β¨ SYNOPSIS β¨
## Via List::Objects::WithUtils::Array ->
use List::Objects::WithUtils 'array';
my $array = array(qw/ a b c /);
if ( $array->any_items eq 'b' ) {
...
}
if ( $array->all_items eq 'a' ) {
...
}
if ( $array->any_items == qr/^b/ ) {
...
}
## As a Role ->
use Role::Tiny::With;
with 'List::Objects::WithUtils::Role::Array',
'List::Objects::WithUtils::Role::Array::WithJunctions';
see how she just glides in? two ways to do it β either you grab it through List::Objects::WithUtils::Array, or you compose it in yourself as a Role with Role::Tiny::With. both slay. π«Ά
π DESCRIPTION π
so these methods hand you overloaded List::Objects::WithUtils::Array::Junction objects, and you can compare them against values using normal Perl comparison operators. no fancy footwork required, bestie. π
Regular expressions? yes ma'am. you match them by handing a qr// regular expression object to the == or != operators. π₯
no support for the ~~ experimental smart-match operator. not a thing here, don't ask, she said no. π
and here's the fun part β the junction objects you get back are subclasses of List::Objects::WithUtils::Array, which means you can manipulate junctions (of varying degrees of sanity, and I'm quoting the docs there, ngl that's a whole mood π). a simple case might be generating a new junction out of an old junction:
my $list = array(3, 4, 5);
if ( (my $anyof = $list->any_items) > 2 ) {
my $incr = $anyof->map(sub { $_[0] + 1 })->all_items;
if ( $incr > 6 ) {
# ...
}
# Drop junction magic again:
my $plain = array( $incr->all );
}
not me reading that and going "okay main character energy" π§
π any_items
Returns the overloaded any object for the current array; a comparison is true if any items in the array satisfy the condition. it's giving "at least one of y'all". β
π¦ all_items
Returns the overloaded all object for the current array; a comparison is true only if all items in the array satisfy the condition. strict queen. everybody has to show up for this one. π
π AUTHOR π
Jon Portnoy <avenj@cobaltirc.org>
and that's a wrap, bestie π this was List::...ctions(3pm), part of the User Contributed Perl Documentation, running on perl v5.38.2 and dated 2024-03-07 β go forth and junction responsibly, no cap. πβ¨
π¦ where this page comes from
- debian trixie: liblist-objects-withutils-perl 2.028003-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: liblist-objects-withutils-perl 2.028003-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: liblist-objects-withutils-perl 2.028003-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms