| Data-AnyBoolean documentation | Contained in the Data-AnyBoolean distribution. |
Data::AnyBoolean - Check none Perl boolean values.
Version 0.0.0
use Data::AnyBoolean;
if(anyBool( 'yes' )){
print 'True'
}
if(anyBool( 'no' )){
print 'True'
}
Any of the items below are considered false.
undef
/^[Nn][Oo]$/
/^[Ff][Aa][Ll][Ss][Ee]$/
/^[Ff]$/
/^[Oo][Ff][Ff]$/
Any of the items below are considered true.
/^[Yy][Ee][Ss]$/
/^[Tt][Rr][Uu][Ee]$/
/^[Tt]$/
/^[Oo][Nn]$/
If any of the above are not matched, it is evaulated as a standard Perl boolean.
This returns '0' or '1' after checking the value passed for the boolean check.
Zane C. Bowers, <vvelox at vvelox.net>
Please report any bugs or feature requests to bug-data-anybollean at rt.cpan.org, or through
the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Data-AnyBollean. 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 Data::AnyBoolean
You can also look for information at:
Copyright 2009 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.
| Data-AnyBoolean documentation | Contained in the Data-AnyBoolean distribution. |
package Data::AnyBoolean; use warnings; use strict; use Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(anyBool); our @EXPORT_OK = qw(anyBool); our %EXPORT_TAGS = (DEFAULT => [qw(anyBool)]);
our $VERSION = '0.0.0';
sub anyBool{ my $bool=$_[0]; if (!defined( $bool )) { return 0; } #yes/no if ($bool =~/^[Yy][Ee][Ss]$/) { return 1; } if ($bool =~/^[Nn][Oo]$/) { return 0; } #true/false if ($bool =~/^[Tt][Rr][Uu][Ee]$/) { return 1; } if ($bool =~/^[Ff][Aa][Ll][Ss][Ee]$/) { return 0; } #on/off if ($bool =~/^[Oo][Nn]$/) { return 1; } if ($bool =~/^[Oo][Ff][Ff]$/) { return 0; } #t/f if ($bool =~/^[Tt]$/) { return 1; } if ($bool =~/^[Ff]$/) { return 0; } #try it the perl way if ( $bool ) { return 1 } return 0; }
1; # End of Data::AnyBoolean