The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

BSON::Bool - Boolean data for BSON

VERSION

version 0.12

SYNOPSIS

    use BSON;

    my $true  = BSON::Bool->true;
    my $false = BSON::Bool->false;
    my $odd   = BSON::Bool->new( time % 2 )

    print "Odd times!" if $odd;

DESCRIPTION

This module is needed for BSON and it manages BSON's boolean element.

METHODS

new

Main constructor which takes a single parameter. Zero or undef create a false instance, and everything else creates a true instance.

    my $true  = BSON::Bool->new(255);
    my $false = BSON::Bool->new;

true

As a secondary constructor it returns a true instance.

false

As a secondary constructor it returns a false instance.

value

Returns 0 or 1 for false and true.

OVERLOAD

All boolean operations are overloaded, so the class instance can be used as a boolean variable itself.

    if ( BSON::Bool->true ) {
        print "You kick ass!";
    }

SEE ALSO

BSON

AUTHORS

  • minimalist <minimalist@lavabit.com>

  • David Golden <david@mongodb.com>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2015 by minimalist and MongoDB, Inc..

This is free software, licensed under:

  The Apache License, Version 2.0, January 2004