line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package String::Unquotemeta; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
56666
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
62
|
|
4
|
1
|
|
|
1
|
|
8
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
78
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
$String::Unquotemeta::VERSION = '0.1'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub import { |
9
|
1
|
|
|
1
|
|
7
|
no strict 'refs'; # I know, PBG says not to do this helps keep it very simple and light |
|
1
|
|
|
|
|
19
|
|
|
1
|
|
|
|
|
863
|
|
10
|
1
|
|
|
1
|
|
16
|
*{ caller() . '::unquotemeta' } = \&unquotemeta; |
|
1
|
|
|
|
|
26
|
|
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# I know, PBP says no prototypes and I very much agree but I want it to |
14
|
|
|
|
|
|
|
# behave like quotemeta() without a lot of fuss (see tests for details) |
15
|
|
|
|
|
|
|
sub unquotemeta(;$) { |
16
|
27
|
100
|
|
27
|
1
|
23592
|
my ($string) = scalar(@_) ? $_[0] : $_; # quotemeta() "If EXPR is omitted, uses $_." |
17
|
27
|
100
|
|
|
|
68
|
return '' if !defined $string; # quotemeta() undef behavior |
18
|
|
|
|
|
|
|
|
19
|
26
|
|
|
|
|
264
|
$string =~ s/(?:\\(?!\\))//g; |
20
|
26
|
|
|
|
|
68
|
$string =~ s/(?:\\\\)/\\/g; |
21
|
|
|
|
|
|
|
|
22
|
26
|
|
|
|
|
68
|
return $string; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
1; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
__END__ |