Data::AnyBoolean - Check none Perl boolean values.


Data-AnyBoolean documentation Contained in the Data-AnyBoolean distribution.

Index


Code Index:

NAME

Top

Data::AnyBoolean - Check none Perl boolean values.

VERSION

Top

Version 0.0.0

SYNOPSIS

Top

    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.

FUNCTIONS

Top

anyBool

This returns '0' or '1' after checking the value passed for the boolean check.

AUTHOR

Top

Zane C. Bowers, <vvelox at vvelox.net>

BUGS

Top

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.

SUPPORT

Top

You can find documentation for this module with the perldoc command.

    perldoc Data::AnyBoolean




You can also look for information at:

* RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=Data-AnyBoolean

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/Data-AnyBoolean

* CPAN Ratings

http://cpanratings.perl.org/d/Data-AnyBoolean

* Search CPAN

http://search.cpan.org/dist/Data-AnyBoolean/

ACKNOWLEDGEMENTS

Top

COPYRIGHT & LICENSE

Top


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