line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package String::LineNumber; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $DATE = '2014-12-10'; # DATE |
4
|
|
|
|
|
|
|
our $VERSION = '0.01'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
25158
|
use 5.010001; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
32
|
|
7
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
8
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
30
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
3
|
use Exporter; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
333
|
|
11
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
13
|
|
|
|
|
|
|
linenum |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub linenum { |
17
|
4
|
|
|
4
|
1
|
16
|
my ($str, $opts) = @_; |
18
|
4
|
|
100
|
|
|
19
|
$opts //= {}; |
19
|
4
|
|
100
|
|
|
18
|
$opts->{width} //= 4; |
20
|
4
|
|
100
|
|
|
17
|
$opts->{zeropad} //= 0; |
21
|
4
|
|
100
|
|
|
14
|
$opts->{skip_empty} //= 1; |
22
|
|
|
|
|
|
|
|
23
|
4
|
|
|
|
|
5
|
my $i = 0; |
24
|
4
|
|
|
|
|
29
|
$str =~ s/^(([\t ]*\S)?.*)/ |
25
|
20
|
100
|
100
|
|
|
266
|
sprintf(join("", |
|
|
100
|
100
|
|
|
|
|
26
|
|
|
|
|
|
|
"%", |
27
|
|
|
|
|
|
|
($opts->{zeropad} && !($opts->{skip_empty} |
28
|
|
|
|
|
|
|
&& !defined($2)) ? "0" : ""), |
29
|
|
|
|
|
|
|
$opts->{width}, "s", |
30
|
|
|
|
|
|
|
"|%s"), |
31
|
|
|
|
|
|
|
++$i && $opts->{skip_empty} && !defined($2) ? "" : $i, |
32
|
|
|
|
|
|
|
$1)/meg; |
33
|
|
|
|
|
|
|
|
34
|
4
|
|
|
|
|
31
|
$str; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
# ABSTRACT: Give line number to each line of string |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
__END__ |