Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Any print statements at "Processing File" and afterwards are not done until near the end of the program.print "Connecting to database... "; #this print works # Connect to the SQL database my $dbh = DBI->connect($dsn,'username','password',{RaiseError=>0, Prin +tError=>0}); if ($dbh) { print "Connected.\n"; #gets printed }else{ print "Cannot connect to database. (",$dsn,")\nQuitting\n"; exit; } print "Processing File... "; # delayed till near end. my $sth = $dbh->prepare( qq{ SELECT field1 FROM Table WHERE field2 = ?}); open(FILE, 'data'); # gonna process a BIG file while(<FILE>) { $sth->execute($_); # etc etc... } close FILE; print "Done processsing file\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: delayed print statement?
by epoptai (Curate) on Jul 09, 2001 at 11:24 UTC | |
by bwana147 (Pilgrim) on Jul 09, 2001 at 13:59 UTC | |
by the_0ne (Pilgrim) on Jul 09, 2001 at 18:33 UTC | |
|
Re: delayed print statement?
by snowcrash (Friar) on Jul 09, 2001 at 11:36 UTC | |
|
Re: delayed print statement?
by Anonymous Monk on Jul 09, 2001 at 20:12 UTC |