line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Sah::Filter::perl::Str::replace_dashes_with_underscores; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1347
|
use 5.010001; |
|
1
|
|
|
|
|
3
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
18
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
151
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
8
|
|
|
|
|
|
|
our $DATE = '2022-07-16'; # DATE |
9
|
|
|
|
|
|
|
our $DIST = 'Data-Sah-Filter-perl-Str-replace_dashes_with_underscores'; # DIST |
10
|
|
|
|
|
|
|
our $VERSION = '0.002'; # VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub meta { |
13
|
|
|
|
|
|
|
+{ |
14
|
1
|
|
|
1
|
0
|
13
|
v => 1, |
15
|
|
|
|
|
|
|
summary => 'Replace dashes in string with underscores', |
16
|
|
|
|
|
|
|
examples => [ |
17
|
|
|
|
|
|
|
{value=>'foo'}, |
18
|
|
|
|
|
|
|
{value=>'foo-bar', filtered_value=>'foo_bar'}, |
19
|
|
|
|
|
|
|
], |
20
|
|
|
|
|
|
|
description => <<'_', |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Can be useful in schemas like Perl module name (or any other identifier kind of |
23
|
|
|
|
|
|
|
schema which only allowes alphanumeric characters which include underscore but |
24
|
|
|
|
|
|
|
not dash) where you can type dasah (which does not require pressing the Shiff |
25
|
|
|
|
|
|
|
key in most keyboards) and later have the dash canonicalized to undersore. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
_ |
28
|
|
|
|
|
|
|
}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub filter { |
32
|
1
|
|
|
1
|
0
|
23
|
my %args = @_; |
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
|
|
2
|
my $dt = $args{data_term}; |
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
|
|
1
|
my $res = {}; |
37
|
1
|
|
|
|
|
4
|
$res->{expr_filter} = join( |
38
|
|
|
|
|
|
|
"", |
39
|
|
|
|
|
|
|
"do { my \$tmp = $dt; \$tmp =~ s/-/_/g; \$tmp }", |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
|
|
3
|
$res; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
# ABSTRACT: Replace dashes in string with underscores |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |