Getopt...::Util(3pm)
π Getopt::Yath::Util β bestie edition π
okay so this is a User Contributed Perl Documentation page for Getopt::Yath::Util, and it's genuinely one of those little helper modules you don't think about until you need it, and then you're obsessed. we're talking utility functions for Getopt::Yath, no cap. let's get into it π«Ά
β¨ NAME β¨
Getopt::Yath::Util β literally just the utility functions for Getopt::Yath. that's the whole vibe. π
πΈ DESCRIPTION πΈ
it's a lil collection of utility functions for Getopt::Yath. that's it, that's the description, and honestly? iconic of it. π
π SYNOPSIS π
here's how you pull them in:
use Getopt::Yath::Util qw{
fqmod
mod2file
decode_json
encode_json
encode_json_file
decode_json_file
};
see? six little besties, all yours. β¨
π¦ EXPORTS π¦
$module = fqmod($name, $prefix)
$module = fqmod($name, $prefix, no_require => $BOOL)
$module = fqmod($name, \@prefixes)
$module = fqmod($name, \@prefixes, no_require => $BOOL)
so fqmod is the full-qualified-module finder, and it's doing the most (affectionately). what it does: it looks for a module named "${prefix}::${name}" for each prefix you handed it, and it returns the first one it finds that can be loaded. first come, first served, periodt.
and if you pass "no_require => 1"? it will not attempt to load any of them, and will usually just return using the first prefix. lowkey lazy, highkey efficient. π
now the special cases, because there's always lore:
- if
$namestarts with a'+', it's assumed to already be a fully qualified module name, and the module name gets returned with the'+'removed. so the plus is basically a little "I got this" badge. π - if
$namestarts with one of the prefixes, no prefix gets added and the original$namegets returned as-is. no double-prefixing, we're not doing that here.
β οΈ and heads up bestie: this function will throw an exception if it cannot find a valid module. so like... be prepared. wrap it if you're fragile. ππ
$file = mod2file($module)
converts a module name into a filename. that's the whole job, and it does it flawlessly. π
$data = decode_json($json)
decodes a json string into perl data. yep. json goes in, perl comes out. π
$json = encode_json($data)
encodes perl data into a json string, using only ascii characters. ascii only, no cap β that's the whole point of this one. β¨
$file = encode_json_file($data)
encodes the data out to a json file, and a new tempfile filename gets returned. so it yeets your data into a fresh temp file and hands you the name like "here bestie, it's yours now". π
$data = decode_json_file($path)
decodes json from the filename you specified. give it a $path, get your $data back. π§
π₯ SOURCE π₯
the source code repo for Getopt-Yath is living its best life at <http://github.com/Test-More/Getopt-Yath/>. go be nosy, it's free. π
π MAINTAINERS π
- Chad Granum <exodist@cpan.org>
π AUTHORS π
- Chad Granum <exodist@cpan.org>
π COPYRIGHT π
Copyright Chad Granum <exodist7@gmail.com>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See <http://dev.perl.org/licenses/>
and that's the whole page bestie!! π₯³ written for perl v5.40.1, dated 2026-05-10, under the Getopt...::Util(3pm) name β go forth and fqmod responsibly, ily, bye!! πβ¨π¦
π¦ where this page comes from
- ubuntu stonking: libgetopt-yath-perl 2.000011-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