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

  • Truthy

    "0"

So false, off, no, empty string, undef, and numeric 0 are falsy, and all other values (including string '0') 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; and

  • Removing 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.

identical

Return truthy if the given parameters are identical objects. Taken from Test::Identity by Paul Evans, which is licensed under the same terms as Perl itself.