Open file and Splitting String in Perl

What I gonna do is to read a bunch of data from a file, and perform some data processing from the string.

  • split() is the Perl function which I will use for filtering the data.
  • open for reading a file into array.

I took MRTG’s data log to do some data processing. On the first column of MRTG log file is Unix timestamp, I would like to print the unix Timestamp to human readable date and time, the other columns are traffic in and out in bytes, which I want to find out which traffic is more than certain values.

Below is the sample of MRTG’s log file (mrtg.log), it’s more than 1000 lines

Perl script will read the log data, split the data by space on each line into array, perform condition compare and find out the date.

After going through more than 1000 lines of MRTG log, below is the output

This shows there were traffic spike twice during some where in Jan 2009. That’s split() and open in Perl.