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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
#!/usr/bin/perl -w
# preferred scetion order
%allsections = ();
%allsectionslist = ();
%secnames = ( # preferred order
"input" => "0",
"required" => "0",
"additional" => "0",
"advanced" => "0",
"output" => "0",
"unknown" => "0"
);
%secnumber = ( # preferred order
"input" => "1",
"required" => "2",
"additional" => "3",
"advanced" => "4",
"output" => "5",
"unknown" => "0"
);
sub numerically { $allsections{$b} <=> $allsections{$a} }
sub numericallyb { $secnames{$b} <=> $secnames{$a} }
chdir( "$ENV{HOME}/local/share/EMBOSS/acd/");
#chdir( "$ENV{HOME}/devemboss/emboss/acd/");
opendir (ACD,".");
while ($acdfile = readdir(ACD)) {
if ($acdfile !~ /(.*).acd$/) {
# print "Skipping $acdfile\n";
next;
}
if ($acdfile =~ /^[.]/) {
# print "Skipping $acdfile\n";
next;
}
open (ACDFILE, $acdfile) || die "Cannot open $acdfile";
# print "reading $acdfile\n";
$sections = "";
$secnum = 0;
$secname = "unknown";
while ($acdline = <ACDFILE>) {
if ($acdline =~ /^\s*section:\s+(\S+)/) {
if (defined($secnames{$1})) {
$secname = $1;
$calc=0;
if ($secnumber{$secname} <= $secnum) {
print "$acdfile: section $secname out of order $secnumber{$secname} <= $secnum\n";
}
}
}
if ($acdline =~ /\$[\(]/) {
$calc++;
}
if ($acdline =~ /^\s*endsection:\s+(\S+)/) {
if ($1 eq $secname) {
$secnames{$1}++;
$secnum = $secnumber{$secname};
if ($sections ne "") {$sections .= ";"}
$sections .= $1;
if ($calc) {
$sections .= "+";
}
}
}
}
close ACDFILE;
$allsections{$sections}++;
$allsectionslist{$sections} .= "$acdfile\n";
}
foreach $x (sort numericallyb keys (%secnames)) {
printf "%4d %s\n", $secnames{$x}, $x;
}
print "=============\n";
foreach $x (sort numerically keys (%allsections)) {
printf "%4d %s\n", $allsections{$x}, $x;
print "$allsectionslist{$x}";
}
|