#!/usr/bin/perl
require( '../lib/env.pl' );
require( '../lib/cgi-lib.pl' );
require( '../lib/lib.pl' );
require( '../lib/gestrfia.pl' );

my $file ="paperslist.txt";
open (FILE,">$file");
my $sock = init_func( "Papers" );
my $P_sth = $sock->prepare( "select title, authors, abstract ".
				"from paper ".
				"order by id" )
	|| die( "ERROR: ".$P_sock->errstr );
    $P_sth->execute() || die( "ERROR: ".$P_sock->errstr );
while( my( $P_title, $P_authors, $P_abstract) = $P_sth->fetchrow() ) 
{
    print( FILE "Title: $P_title\n");
 #   $P_abstract=~s/\n\n/qqqqqqqqqqqqqq/g;
 #   $P_abstract=~s/\n/ /g;
 #   $P_abstract=~s/qqqqqqqqqqqqqq/\n\n/g;
    my $i=0;
    foreach( split( /;/, $P_authors ) )
    {
	my( $fname, $name, $affil ) = parse_author( $_ );
	if ($i) { print( FILE ", $name $fname");
	      } else { print( FILE "Authors: $name $fname");}
	$i++;
    }
    print( FILE "\n\nAbstract:\n $P_abstract\n\n------------------------------------------------------------------------------\n\n");

}
close (FILE);
$P_sth->finish();
