Read Binary File in Perl

Problem

Given the path to a directory. Write a Perl script to print the average time to open and read all files in that directory. The files should be read in blocks of 64 KB

Solution

This is straightforward problem but we need to pay attention to the fact that files can grow in size so we should not dump the entire file into memory however we will read the file in chunks. For more details please refer to the code below.

Code

Here is the code in Perl

Tags:

Add a Comment

Your email address will not be published. Required fields are marked *