in reply to How to read each line of file into an array and split contnts of each line into array cells

You do not really need to split the lines to find the time. Extract it with a regex and then print the line unless the time is within 6 hours either side of noon:

use strict; use warnings; abs( 1200 - join "", /(\d\d):(\d\d)/ ) < 600 or print while(<DATA>); __DATA__ **FAILED PROD** - BUGS - 08/26/13 @05:12 - BUGS~23AUG13~23AUG13~23AUG1 +3~26AUG13~ **FAILED PROD** - BUGS - 08/26/13 @11:12 - BUGS~23AUG13~23AUG13~23AUG1 +3~26AUG13~1109 **FAILED PROD** - cockroach - 08/29/13 @11:52 -cockroach~29AUG13~29AUG +13~29AUG13~29AUG13~1152 **FAILED PROD** - cockroach - 08/29/13 @18:00 -cockroach~29AUG13~29AUG +13~29AUG13~29AUG13~1152
  • Comment on Re: How to read each line of file into an array and split contnts of each line into array cells
  • Download Code

Replies are listed 'Best First'.
Re^2: How to read each line of file into an array and split contnts of each line into array cells
by Anonymous Monk on Sep 30, 2013 at 12:13 UTC

    "...You do not really need to split the lines to find the time. Extract it with a regex and then print the line..."

    And split doesn't use regex shea? of course I know it does uses

      In my response, there is no reference to Perl's split. Besides being a popular function in Perl, split is also an English verb. Most likely split got its name from split. Now, splitting strings into parts in Perl is often done using split but can be achieved in numerous other ways. All I wanted to say is, that the retrieval of the time is possible by applying a regular expression to the complete line from the log file without splitting it first.

      split might use regex. The statement is still correct: You don't need to use split.