#!/usr/local/bin/perl

###############################################################
# Perl script to 'fix' the gp-bibliography file to ensure
# that all month strings have quotes
# Reads the file and generates a new file on stdout
#
# This is used to generate a version of the gp-bibliography that 
# can then be converted by a modified bibtex2refer script into 
# a refer format file that is acceptable to EndNote 
#
# Pete Martin March 3rd 2000
###############################################################
%months = (
	   'jan', '"January"',
	   'feb', '"February"',
	   'mar', '"March"',
	   'apr', '"April"',
	   'may', '"May"',
	   'jun', '"June"',
	   'jul', '"July"',
	   'aug', '"August"',
	   'sep', '"September"',
	   'oct', '"October"',
	   'nov', '"November"',
	   'dec', '"Decemeber"',
	   'Jan', '"January"',
	   'Feb', '"February"',
	   'Mar', '"March"',
	   'Apr', '"April"',
	   'May', '"May"',
	   'Jun', '"June"',
	   'Jul', '"July"',
	   'Aug', '"August"',
	   'Sep', '"September"',
	   'Oct', '"October"',
	   'Nov', '"November"',
	   'Dec', '"December"'
	   );

while(<>) {

    $thisline = $_;
# Find all month records
    if (/month\s+=\s+/) {
        # Substitute SPCQUOTESPC for all " characters quotes are recognised
	s/\"/ QUOTE /g;
	$op="";
	@bits = split / |,|\n/;
	foreach $bit (@bits) {
	    $m = @months{$bit};
	    if ($m ne "") {
		$op .= $m;
	    } elsif ($bit eq 'QUOTE') {
		$op .= '"';
	    } elsif ($bit eq '#' ) {
		$op .= " # ";
	    } else {
		$op .= $bit;
		$op .= " ";
	    }
	}
	$op .= ",\n";
	$_=$op;
	s/\"\"/\"/g;
	print;
    } else {
	print;
    }
}




