File Coverage

blib/lib/Quote/Reference.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package Quote::Reference;
2              
3 1     1   19852 use warnings;
  1         2  
  1         27  
4 1     1   4 use strict;
  1         2  
  1         29  
5              
6 1     1   823 use Filter::Simple;
  1         26289  
  1         6  
7              
8             =head1 NAME
9              
10             Quote::Reference - Create array refs with qwr(...), hash refs with qhr{...}
11              
12             =cut
13              
14             our $VERSION = '1.0.4';
15              
16             =head1 SYNOPSIS
17              
18             use Quote::Reference;
19              
20             # Set $foo = ['this','is','an','array','reference'];
21             my $foo = qwr( this is an array reference );
22              
23             # Set $bar = {
24             # 'red' => 'FF0000',
25             # 'green' => '00FF00',
26             # 'blue' => '0000FF'
27             # }
28             my $bar = qhr{
29             red FF0000
30             green 00FF00
31             blue 0000FF
32             };
33              
34             =head1 DESCRIPTION
35              
36             This module uses source filtering to allow creating hash and array references
37             just as easily and clean as using qw(...).
38              
39             The following new quotelike operators are created:
40              
41             =head2 qwr(...)
42              
43             This behaves in the same way as qw(...) except that it returns an array
44             reference instead of a list.
45              
46             Mnemonic: qw that returns a reference
47              
48             =head2 qhr(...)
49              
50             This behaves in the same way as qw(...) except that it returns a hash
51             reference instead of a list.
52              
53             Mnemonic: quote for hash references
54              
55             =head1 CAVEATS
56              
57             Since this module is based on source filtering, if you have the strings 'qwr'
58             or 'qhr' anywhere in your code, you will get unexpected results.
59              
60             =head1 FAQ
61              
62             =over 4
63              
64             =item Why? Seems pointless.
65              
66             I originally created this module as an experiment to familiarize myself with
67             creating a CPAN module. With that in mind, I chose something silly and
68             limited in scope. I don't expect anyone'll actually use it. :)
69              
70             =back
71              
72             =cut
73              
74             FILTER_ONLY
75             code_no_comments => sub {s/ qwr \( (.*?) \) /[ qw($1) ]/gsx},
76             code_no_comments => sub {s/ qwr \{ (.*?) \} /[ qw{$1} ]/gsx},
77             code_no_comments => sub {s/ qwr \[ (.*?) \] /[ qw[$1] ]/gsx},
78             code_no_comments => sub {s/ qwr \< (.*?) \> /[ qw<$1> ]/gsx},
79             code_no_comments => sub {s/ qwr (\S) (.*?) \1 /[ qw$1$2$1 ]/gsx},
80             code_no_comments => sub {s/ qhr \( (.*?) \) /{ qw($1) }/gsx},
81             code_no_comments => sub {s/ qhr \{ (.*?) \} /{ qw{$1} }/gsx},
82             code_no_comments => sub {s/ qhr \[ (.*?) \] /{ qw[$1] }/gsx},
83             code_no_comments => sub {s/ qhr \< (.*?) \> /{ qw<$1> }/gsx},
84             code_no_comments => sub {s/ qhr (\S) (.*?) \1 /{ qw$1$2$1 }/gsx},
85             all => sub {
86             $Quote::Reference::DEBUG || return;
87             print STDERR $_;
88             },
89             ;
90              
91             =head1 AUTHOR
92              
93             Anthony Kilna, C<< >> - L
94              
95             =head1 BUGS
96              
97             Please report any bugs or feature requests to C, or through
98             the web interface at L. I will be notified, and then you'll
99             automatically be notified of progress on your bug as I make changes.
100              
101             =head1 SUPPORT
102              
103             You can find documentation for this module with the perldoc command.
104              
105             perldoc Quote::Reference
106              
107             You can also look for information at:
108              
109             =over 4
110              
111             =item * RT: CPAN's request tracker
112              
113             L
114              
115             =item * AnnoCPAN: Annotated CPAN documentation
116              
117             L
118              
119             =item * CPAN Ratings
120              
121             L
122              
123             =item * Search CPAN
124              
125             L
126              
127             =back
128              
129             =head1 COPYRIGHT & LICENSE
130              
131             Copyright 2012 Kilna Companies.
132              
133             This program is free software; you can redistribute it and/or modify it
134             under the terms of either: the GNU General Public License as published
135             by the Free Software Foundation; or the Artistic License.
136              
137             See http://dev.perl.org/licenses/ for more information.
138              
139             =cut
140              
141             1; # End of Quote::Reference