1boolean(3)            User Contributed Perl Documentation           boolean(3)
2
3
4

NAME

6       boolean - Boolean support for Perl
7

SYNOPSIS

9           use boolean;
10
11           do &always if true;
12           do &never if false;
13
14       and:
15
16           use boolean ':all';
17
18           $guess = int(rand(2)) % 2 ? true : false;
19
20           do &something if isTrue($guess);
21           do &something_else if isFalse($guess);
22

DESCRIPTION

24       Most programming languages have a native "Boolean" data type.  Perl
25       does not.
26
27       Perl has a simple and well known Truth System. The following scalar
28       values are false:
29
30           $false1 = undef;
31           $false2 = 0;
32           $false3 = 0.0;
33           $false4 = '';
34           $false5 = '0';
35
36       Every other scalar value is true.
37
38       This module provides basic Boolean support, by defining two special
39       objects: "true" and "false".
40

IMPLEMENTATION NOTE

42       Version 0.20 is a complete rewrite from version 0.12. The old version
43       used XS and had some fundamental flaws. The new version is pure Perl
44       and is more correct. The new version depends on overload.pm to make the
45       true and false objects return 1 and 0 respectively.
46
47       The "null" support found in 0.12 was also removed as superfluous.
48

RATIONALE

50       When sharing data between programming languages, it is important to
51       support the same group of basic types. In Perlish programming
52       languages, these types include: Hash, Array, String, Number, Null and
53       Boolean. Perl lacks native Boolean support.
54
55       Data interchange modules like YAML and JSON can now "use boolean" to
56       encode/decode/roundtrip Boolean values.
57

FUNCTIONS

59       This module defines the following functions:
60
61       true
62           This function returns a scalar value which should evaluate to true.
63           The value is a singleton object, meaning there is only one "true"
64           value in a Perl process at any time. You can check to see whether
65           the value is the "true" object with the isTrue function described
66           below.
67
68       false
69           This function returns a scalar value which should evaluate to
70           false. The value is a singleton object, meaning there is only one
71           "false" value in a Perl process at any time. You can check to see
72           whether the value is the "false" object with the isFalse function
73           described below.
74
75       isTrue($scalar)
76           Returns "boolean::true" if the scalar passed to it is the
77           "boolean::true" object. Returns "boolean::false" otherwise.
78
79       isFalse($scalar)
80           Returns "boolean::true" if the scalar passed to it is the
81           "boolean::false" object. Returns "boolean::false" otherwise.
82
83       isBoolean($scalar)
84           Returns "boolean::true" if the scalar passed to it is the
85           "boolean::true" or "boolean::false" object. Returns
86           "boolean::false" otherwise.
87

EXPORTABLES

89       By default this module exports the "true" and "false" functions.
90
91       The module also defines these export tags:
92
93       :all
94           Exports "true", "false", "isTrue", "isFalse", "isBoolean"
95
96       :test
97           Exports "isTrue", "isFalse", "isBoolean"
98

AUTHOR

100       Ingy doet Net <ingy@cpan.org>
101
103       Copyright (c) 2007, 2008. Ingy doet Net.
104
105       This program is free software; you can redistribute it and/or modify it
106       under the same terms as Perl itself.
107
108       See http://www.perl.com/perl/misc/Artistic.html
109
110
111
112perl v5.12.0                      2008-08-25                        boolean(3)
Impressum