Mitch Raful wrote: > Can someone explain why the following code works: > > #!C:\Perl\bin\Perl.exe > require disk_perflib; > > while(1) { > sleep(5); > print "\n"; > printf "%.0d\%", disk_perflib::GetDisk(); > } > But if I remove the print "\n"; it won't work. However, I can > substitute both the print and printf statements with print "Hello...\n"; > and it works just fine.
It's customary (and often necessary) to end each line of print with a newline "\n". You can turn buffering off and flush after each print with $| = 1; for the currently selected FH. 5.8 seems to have more problems in this area than 5.6 had. >From perlvar man page: autoflush HANDLE EXPR $OUTPUT_AUTOFLUSH $| If set to nonzero, forces a flush right away and after every write or print on the currently selected output channel. Default is 0 (regardless of whether the channel is really buffered by the system or not; "$|" tells you only whether you've asked Perl explicitly to flush after each write). STDOUT will typically be line buffered if output is to the terminal and block buffered otherwise. Setting this variable is useful primarily when you are outputting to a pipe or socket, such as when you are running a Perl program under rsh and want to see the output as it's happening. This has no effect on input buffering. See the getc entry in the perlfunc manpage for that. (Mnemonic: when you want your pipes to be piping hot.) -- ,-/- __ _ _ $Bill Luebkert Mailto:[EMAIL PROTECTED] (_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED] / ) /--< o // // Castle of Medieval Myth & Magic http://www.todbe.com/ -/-' /___/_<_</_</_ http://dbecoll.tripod.com/ (Free site for Perl/Lakers) _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs