When you read a file 'line by line' in your Perl script, your computer is using an IO buffer to read a suitable chunk of file into memory in the background. The mechanics of the system vary between OS's but the idea is to optimise the IO read operations. Reading a chunk of a file into a memory (using a binary read operation) and then parsing it line-by-line introduces an extra step and therefore decreases the speed of the application.