File: README

package info (click to toggle)
libboolean-perl 0.20-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 116 kB
  • ctags: 94
  • sloc: perl: 970; makefile: 15
file content (105 lines) | stat: -rw-r--r-- 3,267 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
NAME
    boolean - Boolean support for Perl

SYNOPSIS
        use boolean;

        do &always if true;
        do &never if false;

    and:

        use boolean ':all';

        $guess = int(rand(2)) % 2 ? true : false;

        do &something if isTrue($guess);
        do &something_else if isFalse($guess);

DESCRIPTION
    Most programming languages have a native "Boolean" data type. Perl does
    not.

    Perl has a simple and well known Truth System. The following scalar
    values are false:

        $false1 = undef;
        $false2 = 0;
        $false3 = 0.0;
        $false4 = '';
        $false5 = '0';

    Every other scalar value is true.

    This module provides basic Boolean support, by defining two special
    objects: "true" and "false".

IMPLEMENTATION NOTE
    Version 0.20 is a complete rewrite from version 0.12. The old version
    used XS and had some fundamental flaws. The new version is pure Perl and
    is more correct. The new version depends on overload.pm to make the true
    and false objects return 1 and 0 respectively.

    The "null" support found in 0.12 was also removed as superfluous.

RATIONALE
    When sharing data between programming languages, it is important to
    support the same group of basic types. In Perlish programming languages,
    these types include: Hash, Array, String, Number, Null and Boolean. Perl
    lacks native Boolean support.

    Data interchange modules like YAML and JSON can now "use boolean" to
    encode/decode/roundtrip Boolean values.

FUNCTIONS
    This module defines the following functions:

    true
        This function returns a scalar value which should evaluate to true.
        The value is a singleton object, meaning there is only one "true"
        value in a Perl process at any time. You can check to see whether
        the value is the "true" object with the isTrue function described
        below.

    false
        This function returns a scalar value which should evaluate to false.
        The value is a singleton object, meaning there is only one "false"
        value in a Perl process at any time. You can check to see whether
        the value is the "false" object with the isFalse function described
        below.

    isTrue($scalar)
        Returns "boolean::true" if the scalar passed to it is the
        "boolean::true" object. Returns "boolean::false" otherwise.

    isFalse($scalar)
        Returns "boolean::true" if the scalar passed to it is the
        "boolean::false" object. Returns "boolean::false" otherwise.

    isBoolean($scalar)
        Returns "boolean::true" if the scalar passed to it is the
        "boolean::true" or "boolean::false" object. Returns "boolean::false"
        otherwise.

EXPORTABLES
    By default this module exports the "true" and "false" functions.

    The module also defines these export tags:

    :all
        Exports "true", "false", "isTrue", "isFalse", "isBoolean"

    :test
        Exports "isTrue", "isFalse", "isBoolean"

AUTHOR
    Ingy dt Net <ingy@cpan.org>

COPYRIGHT
    Copyright (c) 2007, 2008. Ingy dt Net.

    This program is free software; you can redistribute it and/or modify it
    under the same terms as Perl itself.

    See http://www.perl.com/perl/misc/Artistic.html