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