Zhiliang Hu <> wrote:
> I have a perl script that takes a while to run. I inserted a few
> lines in the program to print some progress messages to the console
> (STDOUT) so I know where it is at, like:
>
> #!/usr/bin/perl
> print STDOUT "Please wait "; #-- This is the very first line in the
> script
> open(FILE,">localfile");
You should always, yes *always*, check the return value from open():
open(FILE,">localfile") || die "could not open 'localfile' $!";
You should really be using the 3-argument form of open with
a lexical filehandle:
open my $FILE, '>', 'localfile' or die "could not open 'localfile' $!";
> use DBI;
The 3rd line of your program happens before the 1st and 2nd lines.
That can lead to confusion. It would be better to put what happens
first at the beginning of the program rather than in the middle.
> print FILE "--some stuff...\n";
print $FILE "--some stuff...\n"; # with a lexical filehandle
> print STDOUT "...";
> But it prints out nothing to the screen until the very end, when it
> finishes, it dumps all for STDOUT at once to the screen.
It is clear that you are
Suffering from Buffering
http://perl.plover.com/FAQs/Buffering.html
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"