summaryrefslogtreecommitdiffstats
path: root/scripts/parse-descriptor.pl
blob: e29658bee7e1f49b94b3d2e28d445b75c0d9c728 (plain) (blame)
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
use Carp;

#set command line arguments
my ($infi, $outfi) = @ARGV;
my ($type) = $outfi =~ /\.([^.]+)$/;

open(my $fh, "<", $infi) || croak "can't open $infi: $!";
open(STDOUT, ">", $outfi) || croak "can't open $outfi: $!";

my $lastVend = "";
while (<$fh>) {
    my ($vend, $mod, $set) = split('\t', $_);
    if ($type eq "html") {
	if ($vend eq $lastVend) {
	    printf(", %s", $mod);
	} else {
	    if ($lastVend eq "") {
		printf("<dl><dt>%s</dt><dd>\n\t<ul>\n\t    <li>%s", $vend, $mod);
	    } else {
		printf("</li>\n\t</ul>\n    </dd>\n    <dt>%s</dt><dd>\n\t<ul>\n\t    <li>%s", $vend, $mod);
	    }
	}
    } else {
	if ($vend eq $lastVend) {
	    printf(", %s", $mod);
	} else {
	    if ($lastVend eq "") {
		printf("%s: %s", $vend, $mod);
	    } else {
		printf("\n%s: %s", $vend, $mod);
	    }
	}
    }
    $lastVend = $vend;
}
if ($type eq "html") {
    print("</li>\n\t</ul>\n    </dd>\n</dl>");
}
close $fh;