NAME Lingua::Boolean - comprehensively parse boolean response strings VERSION version 0.001 SYNOPSIS use Lingua::Boolean; # Use functional/procedural interface print "Do it? "; chomp(my $response = <>); if ( boolean $response ) { # YES, y, OK, 1... print "OK, doing it.\n"; } else { # no, N, 0... print "OK, not doing it.\n"; } # Once more, with feeling print "Fait-le? "; chomp($response = <>); if ( boolean $response, 'fr' ) { # OUI print "OK, on le fait.\n"; } else { # non print "OK, on ne le fait pas.\n"; } # Or, use OO interface my $bool = Lingua::Boolean->new('en'); print "Do it? "; chomp($response = <>); if ($bool->boolean($response)) { print "OK, doing it!\n"; } else { print "OK, not doing it.\n"; } DESCRIPTION Does that string look like they said "true" or "false"? To know, you have to check a lot of things. Lingua::Boolean attempts to do that in a single module, and do so for multiple languages. FUNCTIONS import Calling "import()" will, obviously, import subs into your namespace. By default, Lingua::Boolean imports the sub "boolean()". You can request to have "looks_true()", "looks_false()", and "languages()" imported. METHODS new "new()" creates a new "Lingua::Boolean" object. You can optionally give it the code for the language you'll be working with, and only that language will be loaded. If you do so, you needn't pass the language to every call to "boolean()": use Lingua::Boolean qw(); my $bool = Lingua::Boolean->new('fr'); print ($bool->boolean('oui') ? "TRUE\n" : "FALSE\n"); Otherwise, "boolean()" accept the language code as the second parameter: use Lingua::Boolean qw(); my $bool = Lingua::Boolean->new(); print ($bool->boolean('oui', 'fr') ? "TRUE\n" : "FALSE\n"); languages "languages()" returns the list of languages Lingua::Boolean knows about. use Lingua::Boolean; my @languages = Lingua::Boolean::languages(); # qw(English Français ...) When called as an object method, returns the languages that object knows about: use Lingua::Boolean qw(); my $bool = Lingua::Boolean->new('fr'); my @languages = $bool->languages(); # qw(Français) langs "langs()" returns the list of language codes Lingua::Boolean knows about. use Lingua::Boolean; my @lang_codes = Lingua::Boolean::langs(); # qw(en fr ...) When called as an object method, returns the languages that object knows about: use Lingua::Boolean qw(); my $bool = Lingua::Boolean->new('fr'); my @lang_codes = $bool->langs(); # qw(fr) boolean "boolean()" tries to determine if the string *looks* true or *looks* false, and returns true or false accordingly. If both tests fail, dies. By default, uses *en*; pass a language code as the second parameter to check another language. Croaks if the language is unknown to Lingua::Boolean (or the Lingua::Boolean object, if used as an object method). This sub is exported by default, and can be used functionally: use Lingua::Boolean; print (boolean('yes') ? "TRUE\n" : "FALSE\n"); Or, if you prefer object orientation, "boolean()" is also an object method: use Lingua::Boolean qw(); my $bool = Lingua::Boolean->new(); print ($bool->boolean('yes') ? "TRUE\n" : "FALSE\n"); If you specify the language in the constructor, you needn't specify it in the call to "boolean()": use Lingua::Boolean qw(); my $bool = Lingua::Boolean->new('fr'); print ($bool->boolean('OUI') ? "TRUE\n" : "FALSE\n"); EXPORTS By default, Lingua::Boolean exports "boolean()". All other methods must be fully qualified - or use the object oriented interface. AVAILABILITY The latest version of this module is available from the Comprehensive Perl Archive Network (CPAN). Visit to find a CPAN site near you, or see . The development version lives at and may be cloned from . Instead of sending patches, please fork this project using the standard git and github infrastructure. BUGS AND LIMITATIONS No bugs have been reported. Please report any bugs or feature requests through the web interface at . AUTHOR Mike Doherty COPYRIGHT AND LICENSE This software is Copyright (c) 2010 by Mike Doherty. This is free software, licensed under: The GNU General Public License, Version 3, June 2007