Banal-Util-Mini
view release on metacpan or search on metacpan
lib/Banal/Util/Mini.pm view on Meta::CPAN
sub polyvalent { # Helps with the parameter processing of polyvalent (object or class) methods
#######################################
my $proto = shift;
my $self = blessed $proto ? $proto : $proto->new();
my $class = blessed $self;
wantarray ? ($self, $class, $proto) : $self;
}
#######################################
sub msg(@) { # Message text builder to be used in error output (warn, die, ...)
#######################################
my $o = blessed ($_[0]) ? shift : caller();
state $pfx = eval { $o->_msg_pfx(@_) } // '';
join ('', $pfx, @_, "\n")
}
#..........................................................
# STRING/TEXT processing functions
#..........................................................
lib/Banal/Util/Mini.pm view on Meta::CPAN
}
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# ARRAY & LIST related functions
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
######################################
sub tidy_arrayify(;@) { local $_; my @res = ( grep { defined $_ } ( uniq( arrayify( @_) ))) }
#######################################
#=begin STOLEN_FROM_List_MoreUtils
# ------------------------------------------------------
# TAU: The two routines, as well as the comment about 'leaks' were stolen from C<List::MoreUtils>
# The only thing I did was privatizing names and turning 'flatten' into a proper subroutine (instead of a scalar CODE closure)
# That allowed me to get rid of a warning.
# ------------------------------------------------------
# apparently, "leaks" when lexically hidden in arrayify.
# sub flatten { map { (ref $_ and ("ARRAY" eq ref $_ or overload::Method($_, '@{}'))) ? (flatten(@{$_})) : ($_) } @_; }
( run in 0.282 second using v1.01-cache-2.11-cpan-65fba6d93b7 )