forked from therion/therion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makeconvert2.pl
executable file
·54 lines (52 loc) · 1007 Bytes
/
makeconvert2.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
#!/usr/bin/perl
@ls = `ls -1 -R`;
@flist = ();
$cdir = '.';
foreach $ln (@ls) {
if ($ln =~ /(.*)\:$/) {
$cdir = $1;
} elsif ($ln =~ /\S/) {
$ln =~ s/^\s+//;
$ln =~ s/\s+$//;
if ($ln =~ /(\.th$|\.th2$)/) {
push @flist, "$cdir/$ln";
}
}
}
foreach $fn (@flist) {
open(FL,"$fn");
@fls = <FL>;
close(FL);
@flso = ();
$toconv = 1;
$numch = 0;
foreach $fln (@fls) {
if ($fln =~ /endcenterline/) {
$toconv = 0;
}
if ($fln =~ /^\s*centerline\s*$/) {
$toconv = 0;
}
if ($fln =~ /^\s*enddata/) {
$numch++;
$fln =~ s/data/centerline/;
}
if ($fln =~ /^\s*data\s*$/) {
$numch++;
$fln =~ s/data/centerline/;
}
if ($fln =~ /^\s*data\s*(\s+)$/) {
if ($1 =~ /^\-/) {
$numch++;
$fln =~ s/data/centerline/;
}
}
push @flso,$fln;
}
if ($toconv && ($numch > 0)) {
print "$fn ($numch changes)\n";
open(FL,">$fn");
print FL "@flso";
close(FL);
}
}