line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::AnyBoolean; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
18366
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
5
|
1
|
|
|
1
|
|
4
|
use Exporter; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
358
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
8
|
|
|
|
|
|
|
our @EXPORT = qw(anyBool); |
9
|
|
|
|
|
|
|
our @EXPORT_OK = qw(anyBool); |
10
|
|
|
|
|
|
|
our %EXPORT_TAGS = (DEFAULT => [qw(anyBool)]); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Data::AnyBoolean - Check none Perl boolean values. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 VERSION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Version 0.0.0 |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION = '0.0.0'; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 SYNOPSIS |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
use Data::AnyBoolean; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
if(anyBool( 'yes' )){ |
31
|
|
|
|
|
|
|
print 'True' |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
if(anyBool( 'no' )){ |
34
|
|
|
|
|
|
|
print 'True' |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Any of the items below are considered false. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
undef |
40
|
|
|
|
|
|
|
/^[Nn][Oo]$/ |
41
|
|
|
|
|
|
|
/^[Ff][Aa][Ll][Ss][Ee]$/ |
42
|
|
|
|
|
|
|
/^[Ff]$/ |
43
|
|
|
|
|
|
|
/^[Oo][Ff][Ff]$/ |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Any of the items below are considered true. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
/^[Yy][Ee][Ss]$/ |
48
|
|
|
|
|
|
|
/^[Tt][Rr][Uu][Ee]$/ |
49
|
|
|
|
|
|
|
/^[Tt]$/ |
50
|
|
|
|
|
|
|
/^[Oo][Nn]$/ |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
If any of the above are not matched, it is evaulated as a standard |
53
|
|
|
|
|
|
|
Perl boolean. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 FUNCTIONS |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 anyBool |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
This returns '0' or '1' after checking the value passed |
60
|
|
|
|
|
|
|
for the boolean check. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub anyBool{ |
65
|
0
|
|
|
0
|
1
|
|
my $bool=$_[0]; |
66
|
|
|
|
|
|
|
|
67
|
0
|
0
|
|
|
|
|
if (!defined( $bool )) { |
68
|
0
|
|
|
|
|
|
return 0; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
#yes/no |
72
|
0
|
0
|
|
|
|
|
if ($bool =~/^[Yy][Ee][Ss]$/) { |
73
|
0
|
|
|
|
|
|
return 1; |
74
|
|
|
|
|
|
|
} |
75
|
0
|
0
|
|
|
|
|
if ($bool =~/^[Nn][Oo]$/) { |
76
|
0
|
|
|
|
|
|
return 0; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
#true/false |
80
|
0
|
0
|
|
|
|
|
if ($bool =~/^[Tt][Rr][Uu][Ee]$/) { |
81
|
0
|
|
|
|
|
|
return 1; |
82
|
|
|
|
|
|
|
} |
83
|
0
|
0
|
|
|
|
|
if ($bool =~/^[Ff][Aa][Ll][Ss][Ee]$/) { |
84
|
0
|
|
|
|
|
|
return 0; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
#on/off |
88
|
0
|
0
|
|
|
|
|
if ($bool =~/^[Oo][Nn]$/) { |
89
|
0
|
|
|
|
|
|
return 1; |
90
|
|
|
|
|
|
|
} |
91
|
0
|
0
|
|
|
|
|
if ($bool =~/^[Oo][Ff][Ff]$/) { |
92
|
0
|
|
|
|
|
|
return 0; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
#t/f |
96
|
0
|
0
|
|
|
|
|
if ($bool =~/^[Tt]$/) { |
97
|
0
|
|
|
|
|
|
return 1; |
98
|
|
|
|
|
|
|
} |
99
|
0
|
0
|
|
|
|
|
if ($bool =~/^[Ff]$/) { |
100
|
0
|
|
|
|
|
|
return 0; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
#try it the perl way |
104
|
0
|
0
|
|
|
|
|
if ( $bool ) { |
105
|
0
|
|
|
|
|
|
return 1 |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
return 0; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 AUTHOR |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Zane C. Bowers, C<< >> |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 BUGS |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
118
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
119
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 SUPPORT |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
perldoc Data::AnyBoolean |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
You can also look for information at: |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=over 4 |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
L |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
L |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=item * CPAN Ratings |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
L |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=item * Search CPAN |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
L |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=back |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Copyright 2009 Zane C. Bowers, all rights reserved. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
162
|
|
|
|
|
|
|
under the same terms as Perl itself. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=cut |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
1; # End of Data::AnyBoolean |