#! /usr/bin/perl

# This program reads a file with paper information in the format
# title\nauthorlist\n\n and converts it toa bibfile with @inproceedings 
# entries and the year. Author format is not touched.

# (1) quit unless we have the correct number of command-line args
$num_args = $#ARGV + 1;
if ($num_args != 2) {
  print "\nUsage: makebib.pl infile outfile\n";
  exit;
}

#Open two files (and set year)

$infile=$ARGV[0];
$outfile=$ARGV[1];


open(INF,$infile) or die "Can't open code name file: $!\n";
open(OUTF,">$outfile");

# Main loop: read lines and re-format

$i = 0;

while ($line = <INF>)
   {  $i = $i +1; 
      $bibkey = "ICSA".":".$i;
      print OUTF "\@inproceedings{$bibkey,\n";
      
      $title = $line;
      chomp($title);      
      
#      print "$title\n";      
      
      $author = <INF>;       
      chomp($author);      
      print OUTF "AUTHOR = \"$author\",\n";
      print OUTF "TITLE = \"$title\",\n";
#       print OUTF "YEAR = $year\n}\n";      
      # Now the year, } and blank line
      $line = <INF>;      
      print OUTF $line;      
      $line = <INF>;      
      print OUTF $line;      
      $line = <INF>;      
      print OUTF $line;      
  }

# close files
close(INF);
close(OUTF);
