SHARYA...t::Util(3pm)
π SHARYANTO::List::Util β the manual page, bestie edition π
okay so you've landed on the manpage for SHARYANTO::List::Util (in the docs it shows up as SHARYA...t::Util(3pm) in the header, cute little nickname energy β¨). It's a Perl module, it's from the Perl distribution SHARYANTO-Utils, and it is literally just a bag of list utilities. Let's go π
πΈ NAME πΈ
SHARYANTO::List::Util β list utilities, periodt. π
π¦ VERSION π¦
This document describes version 0.77 of SHARYANTO::List::Util (from Perl distribution SHARYANTO-Utils), released on 2015-09-04. She's a lil vintage, we love her anyway π
β¨ FUNCTIONS β¨
Real talk: not exported by default, but they're exportable β so you gotta ask nicely if you want them in your namespace. π«Ά
π uniq_adj(@list) => LIST
Removes adjacent duplicates from a list. The way this works is it behaves more like the Unix utility's uniq instead of List::MoreUtils's uniq function, iykyk. Example bestie:
my @res = uniq(1, 4, 4, 3, 1, 1, 2); # 1, 4, 3, 1, 2
See how the 1s and 4s that aren't next to each other stayed? Yeah. That's the whole vibe. π
π uniq_adj_ci(@list) => LIST
Exactly like uniq_adj, except it's case-insensitive. Same energy, lowercase who? Don't know her. π
π uniq_ci(@list) => LIST
Just like List::MoreUtils' uniq, except case-insensitive. So it's the global dedupe but it doesn't care about your caps lock. π
π find_missing_nums_in_seq(LIST) => LIST
Hand it a list of integers and it hands back the number(s) that are missing in the sequence. Iconic detective behaviour fr fr:
find_missing_nums_in_seq(1, 2, 3, 4, 7, 8); # (5, 6)
She found the gap. Obsessed. β¨
π find_missing_strs_in_seq(LIST) => LIST
Same thing as find_missing_nums_in_seq but for strings/letters "a".."z". Look:
find_missing_strs_in_seq("a", "e", "b"); # ("c", "d")
find_missing_strs_in_seq("aa".."zu", "zz"); # ("zv", "zw", "zx", "zy")
Not me checking the alphabet on her behalf π she's thorough.
π min_in_range($lower, $upper, @list) => $num
Find the lowest number $num in @list that still satisfies $lower <= $num <= $upper. And here's the flexible part β $lower and/or $upper can be undef to express no limit. No limit, no problem, main character energy. π
π minstr_in_range($lower, $upper, @list) => $str
Find the lowest string $str in @list that still satisfies $lower le $x le $upper. Same deal: $lower and/or $upper can be undef to express no limit. π¦
π max_in_range($lower, $upper, @list) => $num
Find the highest number $num in @list that still satisfies $lower <= $num <= $upper. And yes, $lower and/or $upper can be undef to express no limit. π
π maxstr_in_range($lower, $upper, @list) => $str
Find the highest string $str in @list that still satisfies $lower le $x le $upper. $lower and/or $upper can be undef to express no limit. Slay. β
π pick(@list) => $item
Randomly pick one item from the list. And ngl it's actually simply done as:
$_[@_ * rand]
That's it. That's the whole trick. Example:
pick(1, 2, 3); # => 2
pick(1, 2, 3); # => 1
Random is random, bestie, don't come for me π
π pick_n($n, @list) => @picked
Randomly pick n different items from the list. But okay, important caveat so you're not blindsided: there might still be duplicate values in the result if the original list contains duplicates. She picks different positions, not necessarily different values, okay?? π
pick_n(3, 1,2,3,4,5); # => (3,2,5)
pick_n(2, 1,2,3,4,5); # => (3,1)
pick_n(2, 1,1,1,1); # => (1,1)
pick_n(4, 1,2,3); # => (3,1,2)
See that (1,1)? That's the duplicate situation happening live. Not a bug, it's the documented vibe. π₯
π SEE ALSO π
SHARYANTO
π HOMEPAGE π
Please visit the project's homepage at <https://metacpan.org/release/SHARYANTO-Utils>. Go say hi π
π¦ SOURCE π¦
Source repository is at <https://github.com/perlancar/perl-SHARYANTO-Utils>. The code lives there, go peek π¦
π BUGS π
Please report any bugs or feature requests on the bugtracker website <https://rt.cpan.org/Public/Dist/Display.html?Name=SHARYANTO-Utils>
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. Fr fr, a repro is the love language here β no repro, no idea what's happening, bestie π«Ά
π AUTHOR π
perlancar <perlancar@cpan.org>
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2015 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Iconic licensing behaviour, we love a permissive queen β¨
okay that's the whole page!! and for the cute sign-off: this beauty was generated by perl v5.34.0 on 2022-06-17, and the page itself answers to SHARYA...t::Util(3pm) in the header and footer π
π bye bestie, go dedupe something π¦
π¦ where this page comes from
- debian bookworm: libsharyanto-utils-perl 0.77-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libsharyanto-utils-perl 0.77-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libsharyanto-utils-perl 0.77-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libsharyanto-utils-perl 0.77-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libsharyanto-utils-perl 0.77-2 Β· 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