blib/lib/TOML/Dumper/Name.pm | |||
---|---|---|---|
Criterion | Covered | Total | % |
statement | 13 | 15 | 86.6 |
branch | 1 | 2 | 50.0 |
condition | n/a | ||
subroutine | 5 | 5 | 100.0 |
pod | n/a | ||
total | 19 | 22 | 86.3 |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | package TOML::Dumper::Name; | ||||||
2 | 2 | 2 | 7 | use strict; | |||
2 | 3 | ||||||
2 | 50 | ||||||
3 | 2 | 2 | 9 | use warnings; | |||
2 | 3 | ||||||
2 | 58 | ||||||
4 | |||||||
5 | 2 | 2 | 1106 | use subs qw/join format/; | |||
2 | 41 | ||||||
2 | 9 | ||||||
6 | |||||||
7 | 5 | 5 | 7 | sub join { CORE::join '.', map { &format($_) } @_ } | |||
9 | 8 | ||||||
8 | |||||||
9 | sub format { | ||||||
10 | 29 | 29 | 28 | my $name = shift; | |||
11 | 29 | 50 | 96 | return $name if $name =~ /^[A-Za-z0-9_-]+$/; | |||
12 | 0 | $name =~ s/\"/\\\"/; | |||||
13 | 0 | return qq{"$name"}; | |||||
14 | } | ||||||
15 | |||||||
16 | 1; | ||||||
17 | __END__ |