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