fgcr has asked for the wisdom of the Perl Monks concerning the following question:
sub main{ my $log_parsing_files = "/export/home/fio/log_parsing_files"; opendir(FILES,"$log_parsing_files") || die "could not open $log_parsing_files"; #opens directory foreach $name (sort readdir(FILES)) { next unless ($name =~ /\w+\d*$/); &parsefile($name); } } sub parsefile { my $name = shift; my $line; my $value; open (FHIN, "</export/home/fio/log_parsing_files/ $name") || die ("can't open $name for reading.\n"); while (<FHIN>) { $line=$_; #chomp(); $line=~m%(\d+).*%; $line=~s/\s//g; &data_base_insert($line); print "these people where given there 5mb $line\n"; } close FHIN; } sub data_base_insert { my ($line) = @_; $sql = "SELECT user_seq from special_offers where user_seq = $line"; $cmd = $dbh->prepare($sql); $cmd->execute(); $userseq = $cmd->fetchrow; print "COMP: '$userseq' '$line'\n"; if ($userseq eq $line ) { print "There are already in the special offers table $line and $userseq\n"; } else { $sql = "INSERT INTO special_offers (PROMO, PROMODATE, USER_SEQ) VALUES ('XDRIVE', '19-JUNE-00','$line')"; $cmd = $dbh->prepare($sql); $dbh->commit(); $sql= "SELECT quota from user_quota where user_seq = $line"; $cmd = $dbh->prepare($sql); $cmd->execute(); $quota = $cmd->fetchrow; my $newspace= 5120 + $quota; my $sql = "UPDATE user_quota set quota = $newspace where user_seq=$line" ; $cmd = $dbh->prepare($sql); $cmd->execute(); $dbh->commit(); return $line; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Closing program when end of files is reached
by maverick (Curate) on Jul 28, 2000 at 22:58 UTC | |
|
Re: Closing program when end of files is reached
by cwest (Friar) on Jul 28, 2000 at 22:54 UTC | |
|
RE: Closing program when end of files is reached
by chip (Curate) on Jul 29, 2000 at 01:46 UTC | |
|
Re: Closing program when end of files is reached
by ferrency (Deacon) on Jul 28, 2000 at 22:58 UTC |