JSPL::Boolean - Perl class that encapsulates the JavaScript's true and false values.
true
false
In JavaScript, every boolean expression results in one of the two values true or false. Both values, when returned to perl space will be wrapped as instances of JSPL::Boolean. Both perl objects use the overload mechanism to behave as expected.
overload
As in JavaScript the rules to convert other values to boolean values are similar to perl's ones, you seldom need to think about them. But, although is considered bad style, you can found JavaScript code that uses something like the following:
function foo(val) { if(val === true) { ... } }
So the need arises to be able to generate true JavaScript boolean values from perl. In those cases you can use the class methods described next.
Return an object that when passed to JavaScript results in the true value, and when evaluated in a perl expression gives a TRUE value.
my $realJStrue = JSPL::Boolean->True;
The same object that constant "JS_TRUE" in JSPL.
Return an object that when passed to JavaScript results in the false value, and when evaluated in a perl expression gives a FALSE value.
my $realJSfalse = JSPL::Boolean->False;
The same object that constant "JS_FALSE" in JSPL.
To install JSPL, copy and paste the appropriate command in to your terminal.
cpanm
cpanm JSPL
CPAN shell
perl -MCPAN -e shell install JSPL
For more information on module installation, please visit the detailed CPAN module installation guide.