NAME
Eve::Support - an utility class that houses various helper functions
SYNOPSIS
use Eve::Support;
Eve::Support::arguments(\%arg_hash,
my $required_argument, my $optional_argument = 'default value'
);
SUBROUTINES
arguments()
The arguments()
method makes it easier to specify a list of required and optional arguments in any other method. It can be used in both class method calls and usual subroutine calls.
Here is an example in a usual subroutine:
sub usual_subroutine {
my (%arg_hash) = @_;
Eve::Support::arguments(\%arg_hash,
my ($required_argument, $another_required_argument),
my ($optional_argument, $optional_empty_argument) = (1, \undef)
);
}
The same may be done in a class method call:
sub class_method {
my ($self, %arg_hash) = @_;
Eve::Support::arguments(\%arg_hash,
my ($required_argument, $another_required_argument),
my ($optional_argument, $optional_empty_argument)
= ('default', \undef)
);
}
If the function is called in the RVALUE context it skips the redundancy check and returns the rest of arguments that have not been processed as a hash reference.
sub foo {
my (%arg_hash) = @_;
my $rest_hash = Eve::Support::arguments(
\%arg_hash, my $bar);
return $rest_hash;
}
Here the call foo(bar =
1, baz => 2, bad => 3)> will return the hash {'baz' =
2, 'bad' => 3}>.
Arguments
\%arg_hash
-
A reference to a hash of arguments that has been passed into the current method.
@variable_list
-
A list of variables that have to be filled by values from the incoming
\%arg_hash
.
Throws
Eve::Error::Attribute
-
could not get a variable for a named argument, an argument is required or an argument is redundant.
unique()
Arguments
list
Returns
A list containing only unique elements of the passed list.
open()
Arguments
mode
file
Returns
A filehandle.
Throws
indexed_hash()
Arguments
Key-value pair list.
Returns
A hash tied to Tie::IxHash.
trim()
Arguments
A string.
Returns
Trimmed string.
Throws
SEE ALSO
LICENSE AND COPYRIGHT
Copyright 2012 Igor Zinovyev.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.