G'day crazy-duck,

Welcome to the monastery.

You should set up dummy data to test your solution. That data should include boundary conditions (e.g exactly 6am, 1 minute before, and 1 minute after). You also need to be clearer about the range: "between 6pm to 6am" inclusive? exclusive? other?

In the code you posted, there's some problems:

Identifying the lines you want is fairly straightforward. For something this simple, I wouldn't recommend a CPAN module nor a complex calculation. A plain comparison, which is easy to read and, if necessary, easy to adjust, is all that's required.

#!/usr/bin/env perl use strict; use warnings; while (<DATA>) { my ($time, $hours, $mins) = /@((\d\d):(\d\d))/; next unless $hours < 6 || $hours > 17 || $time eq '06:00'; # A line we want is in $_ - process it here, e.g. print; } __DATA__ **FAILED PROD** - BUGS - 08/26/13 @00:00 - ... WANTED 1 **FAILED PROD** - BUGS - 08/26/13 @00:01 - ... WANTED 2 **FAILED PROD** - BUGS - 08/26/13 @05:59 - ... WANTED 3 **FAILED PROD** - BUGS - 08/26/13 @06:00 - ... WANTED 4 **FAILED PROD** - BUGS - 08/26/13 @06:01 - ... NOT WANTED 1 **FAILED PROD** - BUGS - 08/26/13 @12:00 - ... NOT WANTED 2 **FAILED PROD** - BUGS - 08/26/13 @17:59 - ... NOT WANTED 3 **FAILED PROD** - BUGS - 08/26/13 @18:00 - ... WANTED 5 **FAILED PROD** - BUGS - 08/26/13 @18:01 - ... WANTED 6 **FAILED PROD** - BUGS - 08/26/13 @23:59 - ... WANTED 7 **FAILED PROD** - BUGS - 08/26/13 @24:00 - ... WANTED 8 (LAST)

Output:

**FAILED PROD** - BUGS - 08/26/13 @00:00 - ... WANTED 1 **FAILED PROD** - BUGS - 08/26/13 @00:01 - ... WANTED 2 **FAILED PROD** - BUGS - 08/26/13 @05:59 - ... WANTED 3 **FAILED PROD** - BUGS - 08/26/13 @06:00 - ... WANTED 4 **FAILED PROD** - BUGS - 08/26/13 @18:00 - ... WANTED 5 **FAILED PROD** - BUGS - 08/26/13 @18:01 - ... WANTED 6 **FAILED PROD** - BUGS - 08/26/13 @23:59 - ... WANTED 7 **FAILED PROD** - BUGS - 08/26/13 @24:00 - ... WANTED 8 (LAST)

-- Ken


In reply to Re: How to read each line of file into an array and split contnts of each line into array cells by kcott
in thread How to read each line of file into an array and split contnts of each line into array cells by crazy-duck

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.