NAME
Util::Underscore - Common helper functions without having to import them
VERSION
version v1.0.0
SYNOPSIS
use Util::Underscore;
_::croak "$foo must do Some::Role" if not _::does($foo, 'Some::Role');
DESCRIPTION
This module contains various utility functions, and makes them accessible through the _
package. This allows the use of these utilities (a) without much per-usage overhead and (b) without namespace pollution.
It contains functions from the following modules:
Not all functions from those are available, and some have been renamed.
FUNCTION REFERENCE
Scalar::Util
$str = _::blessed $object
$str = _::class $object
-
wrapper for
Scalar::Util::blessed
$int = _::ref_addr $ref
-
wrapper for
Scalar::Util::refaddr
$str = _::ref_type $ref
-
wrapper for
Scalar::Util::reftype
_::ref_weaken $ref
-
wrapper for
Scalar::Util::weaken
_::ref_unweaken $ref
-
wrapper for
Scalar::Util::unweaken
$bool = _::ref_is_weak $ref
-
wrapper for
Scalar::Util::isweak
$scalar = _::new_dual $num, $str
-
wrapper for
Scalar::Util::dualvar
$bool = _::is_dual $scalar
-
wrapper for
Scalar::Util::isdual
$bool = _::is_vstring $scalar
-
wrapper for
Scalar::Util::isvstring
$bool = _::is_numeric $scalar
-
wrapper for
Scalar::Util::looks_like_number
$fh = _::is_open $fh
-
wrapper for
Scalar::Util::openhandle
$bool = _::is_readonly $scalar
-
wrapper for
Scalar::Util::readonly
_::prototype \&code
_::prototype \&code, $new_proto
-
gets or sets the prototype, wrapping either
CORE::prototype
orScalar::Util::set_prototype
$bool = _::is_tainted $scalar
-
wrapper for
Scalar::Util::tainted
List::Util and List::MoreUtils
$scalar = _::reduce { BLOCK } @list
-
wrapper for
List::Util::reduce
$bool = _::any { PREDICATE } @list
-
wrapper for
List::Util::any
$bool = _::all { PREDICATE } @list
-
wrapper for
List::Util::all
$bool = _::none { PREDICATE } @list
-
wrapper for
List::Util::none
$scalar = _::first { PREDICATE } @list
-
wrapper for
List::MoreUtils::first_value
$int = _::first_index { PREDICATE } @list
-
wrapper for
List::MoreUtils::first_index
$scalar = _::last { PREDICATE } @list
-
wrapper for
List::MoreUtils::last_value
$int = _::last_index { PREDICATE } @list
-
wrapper for
List::MoreUtils::last_index
$num = _::max @list
$str = _::max_str @list
-
wrappers for
List::Util::max
andList::Util::maxstr
, respectively. $num = _::min @list
$str = _::min_str @list
-
wrappers for
List::Util::min
andList::Util::minstr
, respectively. $num = _::sum 0, @list
-
wrapper for
List::Util::sum
$num = _::product @list
-
wrapper for
List::Util::product
%kvlist = _::pairgrep { PREDICATE } %kvlist
-
wrapper for
List::Util::pairgrep
($k, $v) = _::pairfirst { PREDICATE } %kvlist
-
wrapper for
List::Util::pairfirst
%kvlist = _::pairmap { BLOCK } %kvlist
-
wrapper for
List::Util::pairmap
@list = _::shuffle @list
-
wrapper for
List::Util::shuffle
$iter = _::natatime $size, @list
-
wrapper for
List::MoreUtils::natatime
@list = _::zip \@array1, \@array2, ...
-
wrapper for
List::MoreUtils::zip
Unlike
List::MoreUtils::zip
, this function directly takes array references, and not array variables. It still uses the same implementation. This change makes it easier to work with anonymous arrayrefs, or other data that isn't already inside a named array variable. @list = _::uniq @list
-
wrapper for
List::MoreUtils::uniq
@list = _::part { INDEX_FUNCTION } @list
-
wrapper for
List::MoreUtils::part
$iter = _::each_array \@array1, \@array2, ...
-
wrapper for
List::MoreUtils::each_arrayref
Carp
_::carp "Message"
-
wrapper for
Carp::carp
_::cluck "Message"
-
wrapper for
Carp::cluck
_::croak "Message"
-
wrapper for
Carp::croak
_::confess "Message"
-
wrapper for
Carp::confess
UNIVERSAL
...and other goodies from Safe::Isa
$bool = _::isa $object, 'Class'
-
wrapper for
$Safe::Isa::_isa
$code = _::can $object, 'method'
-
wrapper for
$Safe::Isa::_can
$bool = _::does $object, 'Role'
-
wrapper for
$Safe::Isa::_DOES
any = $maybe_object->_::safecall(method => @args)
-
wrapper for
$Safe::Isa::_call_if_object
Try::Tiny
The following keywords are available:
_::try
_::catch
_::finally
They are all direct aliases for their namesakes in Try::Tiny
.
BUGS
Please report any bugs or feature requests on the bugtracker website https://github.com/latk/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.
AUTHOR
Lukas Atkinson <amon@cpan.org>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2014 by Lukas Atkinson.
This is free software, licensed under:
The GNU General Public License, Version 3, June 2007