NAME
Data::Hopen::Util::Data - general-purpose data-manipulation functions
FUNCTIONS
Nothing is exported by default --- specify :all
if you want it all.
boolify
Convert a scalar to a Boolean as Perl does, except:
Falsy
/^(false|off|no)$/i
So false
, off
, no
, empty string, undef
, numeric 0
, and string '0'
are falsy, and all other values are truthy.
clone
Clones a scalar or a reference. Thin wrapper around "dclone" in Storable.
dedent
Yet Another routine for dedenting multiline strings. Removes the leading horizontal whitespace on the first nonblank line from all lines. If the first argument is a reference, also trims for use in multiline q()
/qq()
. Usage:
dedent " some\n multiline string";
dedent [], q(
very indented
); # [] (or any ref) means do the extra trimming.
The extra trimming includes:
Removing the initial
\n
, if any; andRemoving trailing horizontal whitespace between the last
\n
and the end of the string.
forward_opts
Returns a list of key-value pairs extracted from a given hashref. Usage:
my %forwarded_opts = forward_opts(\%original_opts, [option hashref,]
'name'[, 'name2'...]);
If the option hashref is given, the following can be provided:
- lc
-
If truthy, lower-case the key names in the output
- '-'
-
If present, add
-
to the beginning of each name in the output. This is useful with Getargs::Mixed.