in reply to Print vs Say with sleep function
You can force print() to print unbuffered like this:
$| = 1;
perl -e 'use v5.10; $| = 1; for (1..10) {print $_; sleep(1);}'
I was looking for a link to the docs to share with you and found this oldie but goodie from the Perl Cookbook: Recipe 7.19. Flushing Output :-)
Hope this helps!
update: Changed link to Perl Cookbook excerpt since the one I originally posted turned out to be to a pirate site! (Of course some might use the same description for Google Books ... but the ORA permission is right there.) I just thought it would be fun to post an example from a classic text; next time I'll stick to the current perldoc, I think.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Print vs Say with sleep function
by raghuprasad241 (Beadle) on Jan 19, 2016 at 22:25 UTC |