NAME
Chooser - A system for choosing a value for something.
VERSION
Version 1.1.0
SYNOPSIS
Takes a string composed of various tests, arguements, and etc and returns a value based on it. See FORMATTING for more information on the string.
use Chooser;
my $foo = choose($string);
...
EXPORT
chooose
FUNCTIONS
choose
This function is used for running a chooser string. See FORMATING for information on the string passed to it.
If any of the lines in the string contain errors, choose returns a error.
There are two returns. The first return is a bolean for if it succedded or not. The second is the choosen value.
FORMATTING
<check>|<expect>|<value>|<wieght>|<arg0>=<argValue0>|<arg1>=<argValue1>...
'|' is used a delimiter and there is no whitespace.
For information on the support checks, see the CHECK sections.
The expect section is the expected turn value for a check. Unless stated other wise it is going to be '0' for false and '1' for true.
The value is the return value for if it is true. The eventual returned one is choosen by the wieght. The highest number takes presdence. If equal, the last value is used.
The wieght is the way for the returned value.
The args are every thing after the wieght. Any thing before the first '=' is considered part of the variable name. The variable name is case sensitive. Everything after the first '=' is considered part of the value of the variable.
CHECKS
pingmac
This test pings a IP to make sure it is in the ARP table and then checks to see if the MAC maches.
The arguement for the IP is "ip".
The arguement for the MAC is "mac".
defgateway
This checks the routing table for the default route and compares it to passed variable.
The arguement "ip" is used for the default gateway.
cidr
This checks if a specific interface or any of them have a address that matches a given CIDR.
The arguement "cidr" is CIDR to be matched.
The arguement "if" is optional arguement for the interface.
hostregex
This runs a regex over the hostname and turns true if it matches.
The arguement "regex" is the regex to use.
eval
This runs some perl code. This requires two things being returned. The first thing that needs returned is success of check. This is if the if there as a error or not with the check. It needs to return true or the choose function returns with an error condition. The second returned value is the value that is checked against expect value.
The arguement "eval" is the arguement that contains the code used for this.
netidentflag
This tests to see if a flag created by netident is present. The directory used is the default netident flag directory, unless the enviromental variable 'NETIDENTFLAGDIR' is set.
The arguement "flag" is used to specify the flag to look for.
AUTHOR
Zane C. Bowers, <vvelox at vvelox.net>
BUGS
Please report any bugs or feature requests to bug-chooser at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Chooser. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Chooser
You can also look for information at:
RT: CPAN's request tracker
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
COPYRIGHT & LICENSE
Copyright 2008 Zane C. Bowers, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.