|
NAMEClass::ParmList - Methods for processing named parameter listsSYNOPSISuse Class::ParmList qw(simple_parms parse_parms); $thingy->some_method({ bgcolor => '#ff0000', textcolor => '#000000' }); sub some_method { my ($self) = shift; my ($parm_ref) = @_; my $parms = Class::ParmList->new ({ -parms => $parm_ref, -legal => [qw (textcolor border cellpadding)], -required => [qw (bgcolor)], -defaults => { bgcolor => "#ffffff", textcolor => "#000000" } }); if (not defined $parms) { my $error_message = Class::ParmList->error; die ($error_message); } # Stuff... } sub another_method { my $self = shift; my ($name,$rank,$serial_number) = simple_parms([qw(name rank serial_number)], @_); #... } sub still_another { my $parms = parse_parms ({ -parms => \@_, -legal => [qw (textcolor border cellpadding)], -required => [qw (bgcolor)], -defaults => { bgcolor => "#ffffff", textcolor => "#000000" } }); if (not defined $parms) { my $error_message = Class::ParmList->error; die ($error_message); } # ... } DESCRIPTIONThis is a simple package for validating calling parameters to a subroutine or method. It allows you to use "named parameters" while providing checking for number and naming of parameters for verifying inputs are as expected and meet any minimum requirements. It also allows the setting of default values for the named parameters if omitted.METHODS
FUNCTIONS
VERSION1.06 2020.10.11CHANGES1.00 1999.06.15 - Initial release 1.01 1999.06.18 - Performance tweaks. Addition of 'make test' support 1.02 1999.06.21 - Fixed '-legal' (broken by performance tweaks in 1.01), removed use of 'use attrs' for portability, extended 'make test' tests. 1.03 2000.12.06 - Added exportable class functions 'simple_parms' and 'parse_parms' and allowed 'stacking' references for parms to the object to improve calling usage. 1.04 2005.09.18 - Added META.yml, Build.PL, Artistic_License.txt GPL_License.txt, LICENSE to distribution. Renamed CHANGES to Changes. Extended build tests to 100% coverage. Minor refactoring of module for speed. Seperated documentation into .pod file. Added POD/POD Coverage tests. 1.05 2006.03.04 - Corrected mis-usage of Carp in error paths that was causing less than useful error messages. Added LICENSE and DISCLAIMER sections to documentation. 1.06 2020.10.11 - Relicensed under the MIT License. Cleanup of test reporting. Updating of build configurations. Addition of GitHub repo information to meta data. Updating of maintainer information. Small changes to examples in POD documentation. COPYRIGHTCopyright Jerilyn Franz and FreeRun Technologies, Inc. All Rights Reserved.LICENSEMIT LicenseCopyright (c) 2020 Jerilyn Franz and Freerun Technologies, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. DISCLAIMERTHIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.Use of this software in any way or in any form, source or binary, is not allowed in any country which prohibits disclaimers of any implied warranties of merchantability or fitness for a particular purpose or any disclaimers of a similar nature. IN NO EVENT SHALL I BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION (INCLUDING, BUT NOT LIMITED TO, LOST PROFITS) EVEN IF I HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE AUTHORJerilyn Franz, <cpan@jerilyn.info>BUGSNone knownTODOMemoization of parameter validation for performance.
Visit the GSP FreeBSD Man Page Interface. |