When we say we read from a file or write to a file in Perl (or any other language for that matter), we don't actually access the file directly and immediately. Instead of that we what we really do is that we ask the operating system to read from the file or write to the file using a "system call". The Operating system (Linux, OSX, Windows, etc.) will do the work on our behalf, but it will try to optimize.

So it won't go and write to the disk immediately when we ask it to write a few characters. Instead of that it will keep the request in memory in a "buffer" and will write it to the disk later, when the buffer is full or when the file is closed.