I'm reading from a database and attempting to write out to several different 
files using a defined format.   I'm using this tutorial on formats as a 
reference.   http://www.webreference.com/programming/perl/format/2.html

When I run the script below, I get the error:
Can't find string terminator "" anywhere before EOF at ./roster-report.pl line 
54.

I *think* I've get everything set up properly, and I'm not sure what I'm 
missing.  The script is below.   Please give me a pointer to the error.

TIA  Dave

#!/usr/bin/perl

use strict;

use DBI;
use Getopt::Long;
our ($opt_league, $opt_div);


&GetOptions("league=s", "div=s");

print "Working on the $opt_league league, division $opt_div\n";

#connect to database
my $dbh = DBI->connect("DBI:mysql:database=efl",
                      'user',
                      'password',
                      ) or die "Can't connect to database";

#set the root directory of the installation
my $rootdir= "/home/dthacker/efl/dev/";


#open teams.dir for reading
open( CLUB, "<$rootdir/teams.dir"  ) or die "Can't open teams.dir : $!";
while (<CLUB>) {
    print $_;
    my $roster_file=$_;
    my $club = substr($_, 0,3);
    my $strsql = <<EOT;

select name, age, nat, st, tk, ps, sh, agg, kab, tab, pab, sab
from players where players.club="$club"
EOT

    my $sth = $dbh->prepare($strsql);


    $sth->execute() or die "Couldn't execute statement: $DBI::errstr; 
stopped";

    my ($name, $age, $nat, $st, $tk, $ps, $sh, $agg, $kab, $tab, $pab, $sab);
FORMAT RF =
      <<<<<<<<<<<<<<  << <<< << << << << << << <<< <<< <<< <<<
      $name, $age, $nat, $st, $tk, $ps, $sh, $agg, $kab, $tab, $pab, $sab
.

    open (RF, ">$roster_file");

    while ( my ($name, $age, $nat, $st, $tk, $ps, $sh, $agg, $kab, $tab, $pab, 
$sab) = $sth->fetchrow_array() ) {
        write RF;
    }

    close RF;

}
$dbh->disconnect();
close CLUB;


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to