| 1 | 1 | ▶ | use 5.008001; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | package LeftPad; | ||||||||||||||||||||||||||||
| 6 | # ABSTRACT: Why should Node.js have all the fun? | ||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | our $VERSION = '0.002'; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use base 'Exporter'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 1 | our @EXPORT = qw/leftpad/; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | #pod =func leftpad | ||||||||||||||||||||||||||||
| 16 | #pod | ||||||||||||||||||||||||||||
| 17 | #pod $string = leftpad( $string, $min_length ); | ||||||||||||||||||||||||||||
| 18 | #pod $string = leftpad( $string, $min_length, $pad_char ); | ||||||||||||||||||||||||||||
| 19 | #pod | ||||||||||||||||||||||||||||
| 20 | #pod Returns a copy of the input string with left padding if the input string | ||||||||||||||||||||||||||||
| 21 | #pod length is less than the minimum length. It pads with spaces unless given a | ||||||||||||||||||||||||||||
| 22 | #pod pad character as a third argument. | ||||||||||||||||||||||||||||
| 23 | #pod | ||||||||||||||||||||||||||||
| 24 | #pod Zero or negative minimum length returns the input string. Only the first | ||||||||||||||||||||||||||||
| 25 | #pod character in the pad-character string is used. Undefined warnings are | ||||||||||||||||||||||||||||
| 26 | #pod suppressed so an undefined input string is treated as an empty string. | ||||||||||||||||||||||||||||
| 27 | #pod | ||||||||||||||||||||||||||||
| 28 | #pod =cut | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | sub leftpad { | ||||||||||||||||||||||||||||
| 31 | 1 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 32 | 13 | ▶ | return "" . $_[0] if $_[1] < 1; | ||||||||||||||||||||||||||
|
Subroutine
leftpad: called CC=4 SCAR=13.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | 10 | ▶ | return sprintf( "%*s", $_[1], $_[0] ) unless defined $_[2] && length $_[2]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $_[2] and length $_[2]
MC/DC100%2/2
defined $_[2] and length $_[2]
defined $_[2]
length $_[2]
Truth table100%3/3
A and B
A= defined $_[2]B= length $_[2]
| |||||||||||||||||||||||||||||
| 34 | 4 | return substr( $_[2], 0, 1 ) x ( $_[1] - length $_[0] ) . $_[0]; | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 1 | 1; | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | # vim: ts=4 sts=4 sw=4 et tw=75: | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | __END__ | ||||||||||||||||||||||||||||