NAME

Getopt::Pad::Util - Helper functions (internal)

DESCRIPTION

This module is internal to Getopt::Pad. It is not part of the public API and can change without notice. Programs use "GetOptions" in Getopt::Pad; this page is for people working on Getopt::Pad itself.

FUNCTIONS

All functions are exported on request.

camelize($name)

The reader name for an option or arg name: split at dashes and underscores, every part after the first with its first letter upper case (log-level becomes logLevel). A spec error if the result is not a valid Perl identifier.

isValidName($name)

Whether $name is a valid option name, alias, arg name or command name: a letter, followed by word characters or dashes.

optionSpelling($name)

An option name as it is typed: -v for a name of one letter, else --verbose.

specError($format, @args)

Dies with Getopt::Pad spec: MESSAGE at FILE line LINE., where FILE and LINE are those of the first caller outside Getopt::Pad, normally the GetOptions call. $! and $? are cleared first, so an uncaught spec error exits with status 255.

scalarsIn($value)

Every single value in $value: the value itself, or the scalars of a list, a mapping or a list of mappings.

processedWith($callback, $result, $value)

$value with every single value in it replaced by $callback->($result, $single); arrayrefs and hashrefs around them are rebuilt in the same shape. undef and a missing $callback leave the value as it is. Options and args use it for processValue.

decodedWord($word)

A command line word as a character string: decoded from UTF-8 unless it is decoded already or is not valid UTF-8, in which case it is returned as it is.

encodedFor($handle, $text)

$text as it is printed on $handle: encoded as UTF-8 when it holds characters and the handle has no encoding layer, else unchanged.

expandTilde($path)

Replaces a leading ~ (alone or followed by /) with $HOME. Returns the path unchanged when HOME is not set.

useColor($handle)

Whether output to $handle should be colored: it is a terminal, NO_COLOR is empty or unset, and TERM is not dumb.

SEE ALSO

Getopt::Pad

AUTHOR

davenonymous <perl@davenonymous.com>

COPYRIGHT AND LICENSE

Copyright 2026 davenonymous

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.