line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
69301
|
use 5.10.1; |
|
1
|
|
|
|
|
14
|
|
2
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
95
|
|
4
|
|
|
|
|
|
|
package String::Cushion; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Vertically pad a string |
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY |
8
|
|
|
|
|
|
|
our $VERSION = '1.0000'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
1; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
|
|
9
|
use Sub::Exporter::Progressive -setup => { |
13
|
|
|
|
|
|
|
exports => [qw/cushion/], |
14
|
|
|
|
|
|
|
groups => { |
15
|
|
|
|
|
|
|
default => [qw/cushion/], |
16
|
|
|
|
|
|
|
}, |
17
|
1
|
|
|
1
|
|
514
|
}; |
|
1
|
|
|
|
|
1073
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub cushion($$;$) { |
20
|
8
|
|
|
8
|
1
|
112
|
my $top_cushion = shift; |
21
|
8
|
|
|
|
|
17
|
my $second = shift; |
22
|
8
|
|
|
|
|
13
|
my $third = shift; |
23
|
|
|
|
|
|
|
|
24
|
8
|
100
|
|
|
|
19
|
my $bottom_cushion = defined $third ? $second : $top_cushion; |
25
|
8
|
100
|
|
|
|
17
|
my $string = defined $third ? $third : $second; |
26
|
|
|
|
|
|
|
|
27
|
8
|
50
|
33
|
|
|
75
|
if($top_cushion !~ m{^\d+$} || $bottom_cushion !~ m{^\d+$}) { |
28
|
0
|
|
|
|
|
0
|
return $string; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
8
|
|
|
|
|
27
|
$string =~ s{\A[\h\v]*\v(?=\h*[^\h\v])}{}; |
32
|
8
|
|
|
|
|
38
|
$string =~ s{([^\h\v]\V*)\v[\h\v]*\z}{$1}; |
33
|
|
|
|
|
|
|
|
34
|
8
|
|
|
|
|
24
|
$string = ("\n" x $top_cushion) . $string . ("\n" x $bottom_cushion); |
35
|
|
|
|
|
|
|
|
36
|
8
|
|
|
|
|
52
|
return $string; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
__END__ |