1constant::boolean(3) User Contributed Perl Documentation constant::boolean(3)
2
3
4
6 constant::boolean - Define TRUE and FALSE constants.
7
9 use constant::boolean;
10
11 use File::Spec;
12
13 sub is_package_exist {
14 my ($package) = @_;
15 return FALSE unless defined $package;
16 foreach my $inc (@INC) {
17 my $filename = File::Spec->catfile(
18 split( /\//, $inc ), split( /\::/, $package )
19 ) . '.pm';
20 return TRUE if -f $filename;
21 };
22 return FALSE;
23 };
24
25 no constant::boolean;
26
28 Defines "TRUE" and "FALSE" constants in caller's namespace. You could
29 use simple values like empty string or zero for false, or any non-empty
30 and non-zero string value as true, but the "TRUE" and "FALSE" constants
31 are more descriptive.
32
33 It is virtually the same as:
34
35 # double "not" operator is used for converting scalar to boolean value
36 use constant TRUE => !! 1;
37 use constant FALSE => !! '';
38
39 The constants exported by "constant::boolean" are not reported by
40 Test::Pod::Coverage, so it is more convenient to use this module than
41 to define "TRUE" and "FALSE" constants by yourself.
42
43 The constants can be removed from class API with "no constant::boolean"
44 pragma or some universal tool like namespace::clean.
45
47 If you find the bug or want to implement new features, please report it
48 at <http://rt.cpan.org/NoAuth/Bugs.html?Dist=constant-boolean>
49
51 Piotr Roszatycki <dexter@cpan.org>
52
54 Copyright 2008, 2009 by Piotr Roszatycki <dexter@cpan.org>.
55
56 This program is free software; you can redistribute it and/or modify it
57 under the same terms as Perl itself.
58
59 See <http://www.perl.com/perl/misc/Artistic.html>
60
61
62
63perl v5.32.1 2021-01-27 constant::boolean(3)