#!/afs/athena/contrib/perl/p

$|=1;
$n = 1 unless ($n = $ARGV[0]);
while(1){
    $url = &input("URL: ");
    $title = &input("Title: ");
    $keywords = &input("Keywords: ");
    
    print("Enter Description\n");
    $desc = &gettext;
    &add($n, $url, $title, $desc, $keywords);
    $n++;
}


sub add {
    local($n, $url, $title, $desc, $keywords) = @_;

    local($site);

    $url=~/http:\/\/([^:]+):/;
    $site = $1;

    open(KI, ">>/afs/sipb/project/www/index/kindex");
    print(KI "$n;$keywords\n");
    close(KI);

    open(DI, ">>/afs/sipb/project/www/index/dindex");
    print(DI "$n$url$title$site$desc\n");
    close(DI);
}

sub input {
    local($prompt) = @_;
    local($x);
    print("$prompt");
    $x = (<STDIN>);
    chop($x);
    $x;
}
sub gettext{
    local($msg);
    $msg = "";
    $line = '';
       print("End with a . on a line by itself.\n");
        while($line ne ".\n") {
                $msg = $msg.$line;
                $line = (<STDIN>);
        }
        $msg;
    }
