Thanks for the help you folks gave me on my format problems earlier. I've
resolved those problems and moved to another! My program is supposed to
create a series of roster files. It creates the files, but only the first
file gets the header I defined in RF_TOP. What do I need to change?
TIA DT
#!/usr/bin/perl
use strict;
use warnings;
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
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);
format RF =
@<<<<<<<<<<< @< @<< @< @< @< @< @<
$name, $age, $nat, $st, $tk, $ps, $sh, $agg
.
format RF_TOP =
Name Age Nat St Tk Ps Sh Ag KAb TAb PAb SAb Gam Sav Ktk Kps Sht Gls
Ass DP Inj Sus
-------------------------------------------------------------------------------------------
.
open (RF, ">$roster_file") or die "Can't open roster file $roster_file";
while ( ($name, $age, $nat, $st, $tk, $ps, $sh, $agg ) =
$sth->fetchrow_array() ) {
write RF;
}
close RF;
}
$dbh->disconnect();
-----format of teams.dir------------
acm.txt
bar.txt
cel.txt
dep.txt
int.txt
lyo.txt
por.txt
ran.txt
rea.txt
val.txt
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/