-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathre-align-text.pl
executable file
·57 lines (54 loc) · 1.36 KB
/
re-align-text.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/perl
#
my $file = shift;
my $gidlen = 0;
my $endlen = 0;
open(IN, "<", $file);
while(<IN>) {
if (/^\[(\S+)\](\s+)(.*?)\s\.\.\.$/) {
my $level = $1;
my $spacing = $2;
my $gidaid = $3;
if ($gidlen < length($gidaid)) { $gidlen = length($gidaid); }
my $line = <IN>;
chomp $line;
$line =~ s/^\[$level\]\s+//;
if ($endlen < length($line)) { $endlen = length($line); }
# print;
}
}
close(IN);
open(IN, "<", $file);
while(<IN>) {
if (/^\[(\S+)\](\s+)(.*?)\s\.\.\.$/) {
my $level = $1;
my $spacing = $2;
my $gidaid = $3;
my $line = <IN>;
chomp $line;
$line =~ s/^\[$level\]\s+//;
my $end = "."x($gidlen+$endlen-length($gidaid)-length($line));
printf "[%s]%s%s %s %s\n", $level, $spacing, $gidaid, $end, $line;
next;
}
if (/^\[(\S+)\](\s+)(.*?)\s\.*\s(.*\-\>.*)$/) {
my $level = $1;
my $spacing = $2;
my $gidaid = $3;
my $line = $4;
my $end = "."x($gidlen+$endlen-length($gidaid)-length($line));
printf "[%s]%s%s %s %s\n", $level, $spacing, $gidaid, $end, $line;
next;
}
if (/^\[(\S+)\](\s+)(.*?)\s+(SUCCESS\s.*)$/) {
my $level = $1;
my $spacing = $2;
my $gidaid = $3;
my $line = $4;
my $end = "."x($gidlen+$endlen-length($gidaid)-length($line));
printf "[%s]%s%s %s %s\n", $level, $spacing, $gidaid, $end, $line;
next;
}
print;
}
close(IN);