
Util::Any - Export any utilities and To create your own Util::Any

Version 0.03

use Util::Any qw/list/;
# you can import any functions of List::Util and List::MoreUtils
print uniq qw/1, 0, 1, 2, 3, 3/;
If you want to choose functions
use Util::Any {list => qw/uniq/};
# you can import uniq function, not import other functions
print uniq qw/1, 0, 1, 2, 3, 3/;
If you want to import All kind of utility functions
use Util::Any qw/all/;
my $o = bless {};
my %hash = (a => 1, b => 2);
# from Scalar::Util
blessed $o;
# from Hash::Util
lock_keys %hash;
If you want to import functions with prefix(ex. list_, scalar_, hash_)
use Util::Any qw/all/, {prefix => 1};
use Util::Any qw/list/, {prefix => 1};
use Util::Any {List => qw/uniq/}, {prefix => 1};
print list_uniq qw/1, 0, 1, 2, 3, 3/;

For the people like the man who cannot remember uniq function is in whether List::Util or List::MoreUtils. And for the newbie who don't know where useful utilities is.
Perl has many modules and they have many utility functions. For example, List::Util, List::MoreUtils, Scalar::Util, Hash::Util, String::Util, String::CamelCase, Data::Dumper etc.
We, Perl users, have to memorize module name and their function name. Using this module, you don't need to memorize module name, only memorize kind of modules and function name.
And this module allow you to create your own utility module, easily. You can create your own module and use this in the same way as Util::Any like the following.
use YourUtil qw/list/;
see CREATE YOUR OWN Util::Any.

use Util::Any qw/list hash/;
Give list of kinds of modules. All functions in moduls are exporeted.
use Util::Any {list => ['uniq'], hash => ['lock_keys']};
Give hash ref whose key is kind and value is function names. Selected functions are exported.
Util::Any can take last argument as option, which should be hash ref.
add kind prefix to function name.
use Util::Any qw/list/, {prefix => 1};
list_uniq(1,2,3,4,5); # it is List::More::Utils's uniq function
see "PREFIX FOR EACH MODULE". Uti::Any itself doesn't have such a definition.
Util::Any doesn't say anything when loading module fails. If you pass debug value, warn or die.
use Util::Any qw/list/, {debug => 1}; # warn
use Util::Any qw/list/, {debug => 2}; # die

Kinds of functions and list of exported functions are below. Note that these modules and version are in my environment(Perl 5.8.4). So, it must be diffrent in your environment.
from Scalar::Util (1.19)
blessed dualvar isvstring isweak looks_like_number openhandle readonly refaddr reftype set_prototype tainted weaken
from Hash::Util (0.05)
hash_seed lock_hash lock_keys lock_value unlock_hash unlock_keys unlock_value
from List::Util (1.19)
first max maxstr min minstr reduce shuffle sum
from List::MoreUtils (0.21)
after after_incl all any apply before before_incl each_array each_arrayref false first_index first_value firstidx firstval indexes insert_after insert_after_string last_index last_value lastidx lastval mesh minmax natatime none notall pairwise part true uniq zip
from String::Util (0.11)
crunch define equndef fullchomp hascontent htmlesc neundef nospace randcrypt randword trim unquote
from String::CamelCase (0.01)
camelize decamelize wordsplit
from Data::Dumper (2.121)
Dumper DumperX

no functions.

Just inherit Util::Any and define $Utils hash ref as the following.
package Util::Yours;
use Clone qw/clone/;
use base qw/Util::Any/;
our $Utils = clone $Util::Any::Utils;
push @{$Utils->{list}}, qw/Your::Favorite::List::Utils/;
1;
In your code;
use Util::Yours qw/list/;
Key must be lower character.
NG $Utils = { LIST => [qw/List::Util/]};
OK $Utils = { list => [qw/List::Util/]};
all cannot be used for key.
NG $Utils = { all => [qw/List::Util/]};
Value is array ref which contained scalar or array ref. Scalar is module name. Array ref is module name and its prefix.
$Utils = { list => ['List::Utils'] };
$Utils = { list => [['List::Utils', 'prefix_']] };

If you want to import many modules and they have same function name. You can specify prefix for each module like the following.
use base qw/Util::Any/;
our $Utils = {
list => [['List::Util' => 'lu_'], ['List::MoreUtils' => 'lmu_']]
};
In your code;
use Util::Yours qw/list/, {module_prefix => 1};

Ktat, <ktat at cpan.org>

Please report any bugs or feature requests to bug-util-any at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Util-Any. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

You can find documentation for this module with the perldoc command.
perldoc Util::Any
You can also look for information at:


Copyright 2008 Ktat, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.