Getopt...::Util(3pm)

πŸ“¦ version 2.000011, in ubuntu stonking

πŸ’– 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 $name starts 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 $name starts with one of the prefixes, no prefix gets added and the original $name gets 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 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