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