Great Monks of Wisdom I need yours cuz mine ran out,

The goal is to go through a particular file that has of course a date and time in it. The date and time are always in the same field for a regex so finding and matching is easy. The problem I'm having is I can't seem to figure out how to match data inside a file. I can match ranges for filenames but I can't seem to get the hang of telling a script okay match a number range internal to a file and grab the line. Here is what the data looks like that I'm matching on. This is an example of one line.
4478 00300 064 01 01/11/19 00:00:41 03 00000092a71228a9 255 01 00:00:3 +0 01 00 00 00 DID 0000000000000000 000 0000000000000000 0000000000000 +000 0000000000000000 000 61<BR>
All the lines look like this except different numbers etc... but the positions are the same. Now the 5th field $5 is the date of course and the $6 is the time.

What I can't figure out is let's say I had like 2000 of these lines and I wanted to get the lines from 00:01:20-00:02:20 and have the lines that were found sent to STDOUT. I can do everything but the number range. Here is my script as of now it will match time and date but only exact time and dates. That's efficient for date since most likely I would search by single days only anyway but the time well that's a problem for me. I can't conceptualize how to do this internally to file. I always just used a range idea on filenames but not inside a file. Here is my script(Of course in it's infant stage yet)....HELP!
#!/usr/bin/perl print "DateSearch = d\n"; print "Timesearch = t\n"; print "Make Your Choice."; chomp($choice = STDIN); if ($choice =~ /d/) { chomp($date = STDIN); open(FILE, "/dave/MVPTEST/mvpdoc"); while (<FILE>) { @lines = split(/\n/, $_); foreach $lines (@lines) { if ($lines =~ /(\d{4})\s(\d{5})\s(\d{3})\s(\d{2})\s(\d{2}\/\d{2}\/\d{2 +})\s(\d{2}\:\d{2}\:\d{2})/) { if ($date =~ /$5/) { print "\n@lines\n"; } } } } } elsif ($choice =~ /t/) { chomp($time = STDIN); open(FILE, "/dave/MVPTEST/mvpdoc"); while (<FILE>) { @lines = split(/\n/, $_); foreach $lines (@lines) { if ($lines =~ /(\d{4})\s(\d{5})\s(\d{3})\s(\d{2})\s(\d{2}\/\d{2}\/\d{2 +})\s(\d{2}\:\d{2}\:\d{2})/) { if ($time =~ /$6/) { print "\n@lines\n"; } } } } }
Any Help would definately be appreciated.
HAPPY NEW YEAR!

The brassmon_k

In reply to Get number ranges from files internally? by brassmon_k

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.