Util::Underscore::References - Functions for introspecting and manipulating references
version v1.4.2
$int = _::ref_addr $reference
$int = _::ref_addr
wrapper for Scalar::Util::refaddr
Scalar::Util::refaddr
This is mostly equivalent to the numification of a reference: 0+$ref. However, that fails for objects which have overloaded addition, which is why you should use this function instead.
0+$ref
The ref address denotes identity: two references with the same address are the same object. However, the same address might be reused later, so storing the address is not useful. Use weak references instead.
$reference: the reference to obtain the address of. If omitted, uses $_.
$_
returns: an integer representing ther reference address if the input is any kind of reference (plain reference or object). If the input is not a reference, undef is returned.
undef
$str = _::ref_type $reference
$str = _::ref_type
wrapper for Scalar::Util::reftype
Scalar::Util::reftype
Accesses the type of the bare reference: SCALAR, REF, ARRAY, HASH, CODE, GLOB, REGEXP. Unfortunately, regexes are special, so _::ref_type qr// is REGEXP while ref qr// is Regexp.
SCALAR
REF
ARRAY
HASH
CODE
GLOB
REGEXP
_::ref_type qr//
ref qr//
Regexp
$reference: the reference to obtain the type of. If omitted, uses $_.
returns: the type of the reference. For blessed references, this will not be the class, but the type of the blessed reference. If the input is not a reference, undef is returned.
_::ref_weaken $reference
_::ref_weaken
Turns the reference into a weak reference.
wrapper for Scalar::Util::weaken
Scalar::Util::weaken
$reference: the reference to weaken. If omitted, uses $_.
returns: n/a
_::ref_unweaken $reference
_::ref_unweaken
Turns a weak reference into a normal reference.
wrapper for Scalar::Util::unweaken
Scalar::Util::unweaken
$reference: the reference to unweaken. If omitted, uses $_.
$bool = _::ref_is_weak $reference
$bool = _::ref_is_weak
Checks whether the given reference is a weak reference.
wrapper for Scalar::Util::isweak
Scalar::Util::isweak
$reference: the reference to check. If omitted, uses $_.
returns: a boolean indicating whether the given $reference was a weak reference.
$reference
These are inspired from Params::Util and Data::Util.
Params::Util
Data::Util
The reference validation routines take one argument (or $_) and return a boolean value. They return true when the value is intended to be used as a reference of that kind: either ref_type $arg is of the requested type, or it is an overloaded object that can be used as a reference of that kind. It will not be checked that an object claims to perform an appropriate role (e.g. $arg->DOES('ARRAY')).
ref_type $arg
$arg->DOES('ARRAY')
_::is_ref (any nonblessed reference)
_::is_ref
_::is_scalar_ref (also references to references)
_::is_scalar_ref
_::is_array_ref
_::is_hash_ref
_::is_code_ref
_::is_glob_ref
_::is_regex (note that regexes are blessed objects, not plain references)
_::is_regex
Please report any bugs or feature requests on the bugtracker website https://github.com/latk/p5-Util-Underscore/issues
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
Lukas Atkinson (cpan: AMON) <amon@cpan.org>
This software is copyright (c) 2017 by Lukas Atkinson.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Util::Underscore, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Util::Underscore
CPAN shell
perl -MCPAN -e shell install Util::Underscore
For more information on module installation, please visit the detailed CPAN module installation guide.