File Coverage

blib/lib/Scalar/Listify.pm
Criterion Covered Total %
statement 13 17 76.4
branch 4 6 66.6
condition n/a
subroutine 4 4 100.0
pod 0 2 0.0
total 21 29 72.4


line stmt bran cond sub pod time code
1             package Scalar::Listify;
2              
3             require 5.005_62;
4 1     1   682 use strict;
  1         2  
  1         41  
5 1     1   5 use warnings;
  1         2  
  1         318  
6              
7             require Exporter;
8              
9             our @ISA = qw(Exporter);
10              
11             # Items to export into callers namespace by default. Note: do not export
12             # names by default without a very good reason. Use EXPORT_OK instead.
13             # Do not simply export all your public functions/methods/constants.
14              
15             # This allows declaration use Scalar::Listify ':all';
16             # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
17             # will save memory.
18              
19             our @EXPORT;
20             @EXPORT = qw(&listify &listify_aref);
21              
22             our $VERSION = '0.03';
23              
24              
25             # Preloaded methods go here.
26              
27             my $sub = 'Scalar::Listify::listify';
28              
29             sub listify {
30              
31 2 50   2 0 6 scalar @_ == 1 or die "$sub only takes one argument and this argument
32             must be a simple scalar or array reference";
33              
34 2         4 my $scalar = shift;
35              
36 2 100       6 if (not ref($scalar)) {
37 1         3 my @ret = ($scalar);
38 1         8 return (@ret);
39             }
40              
41 1 50       11 ref($scalar) eq 'ARRAY' and return @$scalar;
42              
43 0         0 require Data::Dumper;
44 0         0 my $err = "Scalar::Listify::listify error - this function only takes
45             simple scalars or references to arrays. I'm not sure what you gave me, but
46             here is what Data::Dumper has to say about it:";
47 0         0 warn $err;
48 0         0 warn Data::Dumper->Dump([$scalar],['bad_data']);
49              
50             }
51              
52             sub listify_aref {
53              
54 2     2 0 217 [ listify @_ ]
55              
56             }
57              
58             1;
59             __END__