Modified source files and compiled any and armel versions of packages
[pkg-perl] / deb-src / libperl-critic-perl / libperl-critic-perl-1.088 / lib / Perl / Critic / Utils / DataConversion.pm
1 ##############################################################################
2 #      $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/Perl-Critic/lib/Perl/Critic/Utils/DataConversion.pm $
3 #     $Date: 2007-09-02 21:31:09 -0500 (Sun, 02 Sep 2007) $
4 #   $Author: clonezone $
5 # $Revision: 1859 $
6 ##############################################################################
7
8 package Perl::Critic::Utils::DataConversion;
9
10 use 5.006001;
11 use strict;
12 use warnings;
13 use Readonly;
14
15 use Perl::Critic::Utils qw{ :characters :booleans };
16
17 use base 'Exporter';
18
19 our $VERSION = '1.088';
20
21 #-----------------------------------------------------------------------------
22
23 Readonly::Array our @EXPORT_OK => qw(
24     boolean_to_number
25     dor
26     defined_or_empty
27 );
28
29 #-----------------------------------------------------------------------------
30
31 sub boolean_to_number {  ## no critic (RequireArgUnpacking)
32     return $_[0] ? $TRUE : $FALSE;
33 }
34
35 #-----------------------------------------------------------------------------
36
37 sub dor {  ## no critic (RequireArgUnpacking)
38     return defined $_[0] ? $_[0] : $_[1];
39 }
40
41 #-----------------------------------------------------------------------------
42
43 sub defined_or_empty {  ## no critic (RequireArgUnpacking)
44     return defined $_[0] ? $_[0] : $EMPTY;
45 }
46
47 1;
48
49 __END__
50
51 #-----------------------------------------------------------------------------
52
53 =pod
54
55 =for stopwords
56
57 =head1 NAME
58
59 Perl::Critic::Utils::DataConversion - Utilities for converting from one type of data to another.
60
61 =head1 DESCRIPTION
62
63 Provides data conversion functions.
64
65
66 =head1 IMPORTABLE SUBS
67
68 =over
69
70 =item C<boolean_to_number( $value )>
71
72 Return 0 or 1 based upon the value of parameter in a boolean context.
73
74
75 =item C<dor( $value, $default )>
76
77 Return either the value or the default based upon whether the value is
78 defined or not.
79
80
81 =item C<defined_or_empty( $value )>
82
83 Return either the parameter or an empty string based upon whether the
84 parameter is defined or not.
85
86
87 =back
88
89
90 =head1 AUTHOR
91
92 Elliot Shank <perl@galumph.com>
93
94 =head1 COPYRIGHT
95
96 Copyright (c) 2007-2008 Elliot Shank.  All rights reserved.
97
98 This program is free software; you can redistribute it and/or modify
99 it under the same terms as Perl itself.  The full text of this license
100 can be found in the LICENSE file included with this module.
101
102 =cut
103
104 # Local Variables:
105 #   mode: cperl
106 #   cperl-indent-level: 4
107 #   fill-column: 78
108 #   indent-tabs-mode: nil
109 #   c-indentation-style: bsd
110 # End:
111 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :