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) $
6 ##############################################################################
8 package Perl::Critic::Utils::DataConversion;
15 use Perl::Critic::Utils qw{ :characters :booleans };
19 our $VERSION = '1.088';
21 #-----------------------------------------------------------------------------
23 Readonly::Array our @EXPORT_OK => qw(
29 #-----------------------------------------------------------------------------
31 sub boolean_to_number { ## no critic (RequireArgUnpacking)
32 return $_[0] ? $TRUE : $FALSE;
35 #-----------------------------------------------------------------------------
37 sub dor { ## no critic (RequireArgUnpacking)
38 return defined $_[0] ? $_[0] : $_[1];
41 #-----------------------------------------------------------------------------
43 sub defined_or_empty { ## no critic (RequireArgUnpacking)
44 return defined $_[0] ? $_[0] : $EMPTY;
51 #-----------------------------------------------------------------------------
59 Perl::Critic::Utils::DataConversion - Utilities for converting from one type of data to another.
63 Provides data conversion functions.
66 =head1 IMPORTABLE SUBS
70 =item C<boolean_to_number( $value )>
72 Return 0 or 1 based upon the value of parameter in a boolean context.
75 =item C<dor( $value, $default )>
77 Return either the value or the default based upon whether the value is
81 =item C<defined_or_empty( $value )>
83 Return either the parameter or an empty string based upon whether the
84 parameter is defined or not.
92 Elliot Shank <perl@galumph.com>
96 Copyright (c) 2007-2008 Elliot Shank. All rights reserved.
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.
106 # cperl-indent-level: 4
108 # indent-tabs-mode: nil
109 # c-indentation-style: bsd
111 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :