#!/usr/bin/perl -wT
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use strict;

print header;
print "<html><head><title>Publication in Bibtex Format</title></head><body>\n";
open(FH,"/fs/wwwusers/abadi/pubs/abadirefs.bib") or &dienice("Can't open users file: $!");
my $where = 0;
my $currkey;
while(<FH>) {               #loop as long as not EOF
    my $a = $_;                   #loop variable -- contains current line
    my @b = split(' ', $a);
    if (substr($b[0],0,1) eq "\@") {
        $a =~ m/(\{.*,)/;
        $currkey = substr($1,1);
        chop($currkey);
	if ($currkey eq param('v')) {
	    $where = 1;
	}
	else {
	    $where = 0;
	}
    }
    if ($where == 1) {
	if ($b[1] eq "=") {
	    if (($b[0] ne "abstract") && ($b[0] ne "url_Paper") && ($b[0] ne "pdfKB") && ($b[0] ne "publicationtype") && ($b[0] ne "award") && ($b[0] ne "url_Slides") && ($b[0] ne "iis1527118") && ($b[0] ne "iis1718581") && ($b[0] ne "iis1910613") && ($b[0] ne "displayCategory") && ($b[0] ne "nsfclue") && ($b[0] ne "iis0845643") && ($b[0] ne "iis1249722") && ($b[0] ne "note") && ($b[0] ne "venue"))  {
		    print $a, "<br>\n";
	    }
	}
	else {
	    print $a, "<br>\n";
	}
    }
    if (substr($b[0],0,1) eq "}") {
	$where = 0;
    }

}
close(FH);
print "</body></html>\n";

sub dienice {
    my($errmsg) = @_;
    print "<h2>Error</h2>\n";
    print "<p>$errmsg</p>\n";
    print end_html;
    exit;
}
