line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Acme::Indent; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
998
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
4
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
16
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
613
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
require Exporter; |
9
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
10
|
|
|
|
|
|
|
our @EXPORT = qw(ai); |
11
|
|
|
|
|
|
|
our @EXPORT_OK = qw(); |
12
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub ai { |
15
|
2
|
|
|
2
|
0
|
1252
|
my @lines = split m{\n}xms, $_[0]; |
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
|
|
4
|
my $result = ''; |
18
|
2
|
|
|
|
|
4
|
my $empty = ''; |
19
|
|
|
|
|
|
|
|
20
|
2
|
|
|
|
|
4
|
my $shft = 0; |
21
|
2
|
|
|
|
|
3
|
my $data = 0; |
22
|
|
|
|
|
|
|
|
23
|
2
|
|
|
|
|
4
|
for my $l (@lines) { |
24
|
20
|
100
|
|
|
|
41
|
unless ($data) { |
25
|
4
|
100
|
|
|
|
14
|
if ($l =~ m{\A (\s*) \S}xms) { |
26
|
2
|
|
|
|
|
5
|
$shft = length($1); |
27
|
2
|
|
|
|
|
5
|
$data = 1; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
20
|
100
|
|
|
|
41
|
if ($data) { |
32
|
18
|
|
|
|
|
19
|
my ($spaces, $text); |
33
|
|
|
|
|
|
|
|
34
|
18
|
100
|
|
|
|
34
|
if (length($l) >= $shft) { |
35
|
16
|
|
|
|
|
24
|
$spaces = substr($l, 0, $shft); |
36
|
16
|
|
|
|
|
29
|
$text = substr($l, $shft); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
else { |
39
|
2
|
|
|
|
|
6
|
$spaces = $l; |
40
|
2
|
|
|
|
|
4
|
$text = ''; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
18
|
100
|
|
|
|
41
|
if ($spaces =~ m{\S}xms) { |
44
|
1
|
|
|
|
|
230
|
carp "Found characters ('$spaces') in indentation zone"; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
18
|
100
|
|
|
|
126
|
if ($text =~ m{\S}xms) { |
48
|
15
|
|
|
|
|
29
|
$result .= $empty.$text."\n"; |
49
|
15
|
|
|
|
|
31
|
$empty = ''; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
else { |
52
|
3
|
|
|
|
|
6
|
$empty .= "\n"; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
2
|
|
|
|
|
9
|
return $result; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
__END__ |