From the course: Perl 5 Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

The autoflush variable

The autoflush variable - Perl Tutorial

From the course: Perl 5 Essential Training

Start my 1-month free trial

The autoflush variable

- [Voiceover] Output buffering is a necessary evil. In order for a system to be able to handle large amounts of data, it must buffer that data. It collects data up and then spits it out all at once when its buffers are full or according to some algorithm. Unfortunately, it generally has no easy way to determine when to flush its buffers. This is especially bothersome with the standard output stream. In this example, I have a silly little script that asks you for your favorite number and then it gives you a better number. The better number is somewhat random, so it may be different when you run it. Let's go ahead and run it. Now there is a prompt here. You see it says, "What is your favorite number? " And you notice my prompt is not showing up in my output. But if I come in here and I type a number, say 42, it now gives me the prompt after and then it gives me the answer also. Like I said, it's silly. So you may also notice that this doesn't behave the same way on different systems or…

Contents