#!/usr/bin/perl

&init_labels;
&fixinfo;

sub init_labels {
    open(LABELS, "labels.pl");
    <LABELS>;
    <LABELS>;
    <LABELS>;
    <LABELS>;
    while (<LABELS>) {
	@words = split(/\//);
	$key = @words[1];
	$_ = <LABELS>;
	@words = split(/\|/);
	$node = @words[1];
	chop($node);
	if ($key =~ /..*/) {
		$label{$key} = $node;
	}
	<LABELS>;
	<LABELS>;
    }
    close(LABELS);
}

sub fixinfo {
    open(INFO, "wave/misc/wave.inf");
    while (<INFO>) {
	if ($_ =~ /:.*:%*%/) {
	    @words = split(/%/);
	    $key = @words[1];
	    print "@words[0]url_view /usr/help/html/wug/$label{$key}\n";
	}
	else {
	   print $_;
        }
    }
    close(INFO);
}
