blib/lib/Quote/Reference.pm

filter: Statementstmt 95.8% 23 / 24 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 14 / 14 Podpod n/a totaltotal 95.0% 38 / 40 CC 2 SCAR 1.8
CC
2
Cov
92%
__ANON__
2.5
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
↑ Summary
1 package Quote::Reference;
2  
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use Filter::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 =head1 NAME
9  
10 Quote::Reference - Create array refs with qwr(...), hash refs with qhr{...}
11  
12 =cut
13  
14 2 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 1 ▶ code_no_comments => sub {s/ qwr \( (.*?) \) /[ qw($1) ]/gsx},
Subroutine __ANON__: called CC=1 SCAR=0.0
76 1 ▶ code_no_comments => sub {s/ qwr \{ (.*?) \} /[ qw{$1} ]/gsx},
Subroutine __ANON__: called CC=1 SCAR=0.0
77 1 ▶ code_no_comments => sub {s/ qwr \[ (.*?) \] /[ qw[$1] ]/gsx},
Subroutine __ANON__: called CC=1 SCAR=0.0
78 1 ▶ code_no_comments => sub {s/ qwr \< (.*?) \> /[ qw<$1> ]/gsx},
Subroutine __ANON__: called CC=1 SCAR=0.0
79 1 ▶ code_no_comments => sub {s/ qwr (\S) (.*?) \1 /[ qw$1$2$1 ]/gsx},
Subroutine __ANON__: called CC=1 SCAR=0.0
80 1 ▶ code_no_comments => sub {s/ qhr \( (.*?) \) /{ qw($1) }/gsx},
Subroutine __ANON__: called CC=1 SCAR=0.0
81 1 ▶ code_no_comments => sub {s/ qhr \{ (.*?) \} /{ qw{$1} }/gsx},
Subroutine __ANON__: called CC=1 SCAR=0.0
82 1 ▶ code_no_comments => sub {s/ qhr \[ (.*?) \] /{ qw[$1] }/gsx},
Subroutine __ANON__: called CC=1 SCAR=0.0
83 1 ▶ code_no_comments => sub {s/ qhr \< (.*?) \> /{ qw<$1> }/gsx},
Subroutine __ANON__: called CC=1 SCAR=0.0
84 1 ▶ code_no_comments => sub {s/ qhr (\S) (.*?) \1 /{ qw$1$2$1 }/gsx},
Subroutine __ANON__: called CC=1 SCAR=0.0
85 1 ▶ all => sub {
Subroutine __ANON__: called CC=2 SCAR=9.2
86 1 ▶ $Quote::Reference::DEBUG || return;
Branch: 1 branch
BranchTrueFalseTotal
$Quote::Reference::DEBUG or return 0 1 1
87 0 print STDERR $_;
88 },
89 2 ;
90  
91 =head1 AUTHOR
92  
93 Anthony Kilna, C<< <anthony at kilna.com> >> - L<http://anthony.kilna.com>
94  
95 =head1 BUGS
96  
97 Please report any bugs or feature requests to C<bug-quote-reference at rt.cpan.org>, or through
98 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Quote-Reference>. 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<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Quote-Reference>
114  
115 =item * AnnoCPAN: Annotated CPAN documentation
116  
117 L<http://annocpan.org/dist/Quote-Reference>
118  
119 =item * CPAN Ratings
120  
121 L<http://cpanratings.perl.org/d/Quote-Reference>
122  
123 =item * Search CPAN
124  
125 L<http://search.cpan.org/dist/Quote-Reference>
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 2 1; # End of Quote::Reference
↑ Summary