| 1 | 2 | ▶ | use 5.10.1; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | package String::Cushion; | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | # ABSTRACT: Vertically pad a string | ||||||||||||||||||||||||||||
| 7 | 2 | our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY | |||||||||||||||||||||||||||
| 8 | 2 | our $VERSION = '1.0000'; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 2 | 1; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use Sub::Exporter::Progressive -setup => { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | exports => [qw/cushion/], | ||||||||||||||||||||||||||||
| 14 | groups => { | ||||||||||||||||||||||||||||
| 15 | default => [qw/cushion/], | ||||||||||||||||||||||||||||
| 16 | }, | ||||||||||||||||||||||||||||
| 17 | 2 | }; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 8 | ▶ | sub cushion($$;$) { | ||||||||||||||||||||||||||
|
Subroutine
cushion: called CC=5 SCAR=16.5
Pod
documented
| |||||||||||||||||||||||||||||
| 20 | 8 | my $top_cushion = shift; | |||||||||||||||||||||||||||
| 21 | 8 | my $second = shift; | |||||||||||||||||||||||||||
| 22 | 8 | my $third = shift; | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 8 | ▶ | my $bottom_cushion = defined $third ? $second : $top_cushion; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | 8 | ▶ | my $string = defined $third ? $third : $second; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 8 | ▶ | if($top_cushion !~ m{^\d+$} || $bottom_cushion !~ m{^\d+$}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$top_cushion =~ /^\d+$/ and $bottom_cushion =~ /^\d+$/
MC/DC0%0/2
$top_cushion =~ /^\d+$/ and $bottom_cushion =~ /^\d+$/
$top_cushion =~ /^\d+$/
$bottom_cushion =~ /^\d+$/
Truth table33%1/3
A and B
A= $top_cushion =~ /^\d+$/B= $bottom_cushion =~ /^\d+$/
| |||||||||||||||||||||||||||||
| 28 | 0 | return $string; | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 8 | $string =~ s{\A[\h\v]*\v(?=\h*[^\h\v])}{}; | |||||||||||||||||||||||||||
| 32 | 8 | $string =~ s{([^\h\v]\V*)\v[\h\v]*\z}{$1}; | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 8 | $string = ("\n" x $top_cushion) . $string . ("\n" x $bottom_cushion); | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 8 | return $string; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 2 | 1; | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | __END__ | ||||||||||||||||||||||||||||