line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::ToPerl6::Utils::DataConversion; |
2
|
|
|
|
|
|
|
|
3
|
25
|
|
|
25
|
|
532
|
use 5.006001; |
|
25
|
|
|
|
|
72
|
|
4
|
25
|
|
|
25
|
|
112
|
use strict; |
|
25
|
|
|
|
|
40
|
|
|
25
|
|
|
|
|
545
|
|
5
|
25
|
|
|
25
|
|
107
|
use warnings; |
|
25
|
|
|
|
|
33
|
|
|
25
|
|
|
|
|
854
|
|
6
|
25
|
|
|
25
|
|
99
|
use Readonly; |
|
25
|
|
|
|
|
35
|
|
|
25
|
|
|
|
|
1254
|
|
7
|
|
|
|
|
|
|
|
8
|
25
|
|
|
25
|
|
116
|
use Perl::ToPerl6::Utils qw{ :characters :booleans }; |
|
25
|
|
|
|
|
38
|
|
|
25
|
|
|
|
|
1332
|
|
9
|
|
|
|
|
|
|
|
10
|
25
|
|
|
25
|
|
5385
|
use Exporter 'import'; |
|
25
|
|
|
|
|
33
|
|
|
25
|
|
|
|
|
4067
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Readonly::Array our @EXPORT_OK => qw( |
17
|
|
|
|
|
|
|
boolean_to_number |
18
|
|
|
|
|
|
|
dor |
19
|
|
|
|
|
|
|
defined_or_empty |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub boolean_to_number { |
25
|
365
|
100
|
|
365
|
1
|
1038
|
return $_[0] ? $TRUE : $FALSE; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub dor { |
31
|
3775
|
|
|
3775
|
1
|
5611
|
foreach (@_) { |
32
|
8867
|
100
|
|
|
|
17734
|
return $_ if defined; |
33
|
|
|
|
|
|
|
} |
34
|
0
|
|
|
|
|
|
return; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub defined_or_empty { |
40
|
0
|
0
|
|
0
|
1
|
|
return defined $_[0] ? $_[0] : $EMPTY; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
__END__ |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=pod |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=for stopwords |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 NAME |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Perl::ToPerl6::Utils::DataConversion - Utilities for converting from one type of data to another. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 DESCRIPTION |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Provides data conversion functions. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 INTERFACE SUPPORT |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
This is considered to be a public module. Any changes to its |
67
|
|
|
|
|
|
|
interface will go through a deprecation cycle. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 IMPORTABLE SUBS |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=over |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=item C<boolean_to_number( $value )> |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Return 0 or 1 based upon the value of parameter in a boolean context. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=item C<dor( $value, $default )> |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Return either the value or the default based upon whether the value is |
82
|
|
|
|
|
|
|
defined or not. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item C<dor_n( $value0, $value1, ... )> |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Returns the first defined value among its arguments. If none is defined, |
87
|
|
|
|
|
|
|
simply returns. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item C<defined_or_empty( $value )> |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Return either the parameter or an empty string based upon whether the |
94
|
|
|
|
|
|
|
parameter is defined or not. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=back |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 AUTHOR |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Elliot Shank <perl@galumph.com> |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 COPYRIGHT |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Copyright (c) 2007-2011 Elliot Shank. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
109
|
|
|
|
|
|
|
it under the same terms as Perl itself. The full text of this license |
110
|
|
|
|
|
|
|
can be found in the LICENSE file included with this module. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=cut |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# Local Variables: |
115
|
|
|
|
|
|
|
# mode: cperl |
116
|
|
|
|
|
|
|
# cperl-indent-level: 4 |
117
|
|
|
|
|
|
|
# fill-column: 78 |
118
|
|
|
|
|
|
|
# indent-tabs-mode: nil |
119
|
|
|
|
|
|
|
# c-indentation-style: bsd |
120
|
|
|
|
|
|
|
# End: |
121
|
|
|
|
|
|
|
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : |