Fellow Monks I need your brain power,

I've been doing PERL for like 6 months and I'm not that good at regular expressions such as for pattern matching. I'll show you the script I have first. Then show you the data it needs to read and show you what I want out of it. Here is the script.
#!/usr/bin/perl -w use strict; my %mylist; my $min; my $max; my $range; my $line; # get the range (in this throwtogether it must be entered # with no spaces in the form HHMMSSTT-HHMMSSTT) # Hour, Minute, Second, Tenths of seconds # Get the range $range = <STDIN>; # Break up the range ($min, $max) = split /-/, $range; # Squeeze out leading and trailing spaces $min =~ s/^\s+//; $min =~ s/\s+$//; $max =~ s/^\s+//; $max =~ s/\s+$//; # Get the filenames and break into fields open(CAT, "cat mon402.log |"); (@ARGV = <CAT>) unless @ARGV; for (@ARGV) { if ($_ =~ m/(\d{2}\-\w{3}\-\d{4})\ (\d{2}\:\d{2}\:\d{2}\.\d{2})/) +{ # push the restricted range of filenames onto a hash of arrays + # keyed on the date field if (($2>= $min) && ($2 <= $max)) { push(@{$mylist{$2}}, $_); } } } my @keys = sort (keys %mylist); foreach my $key (@keys) { foreach my $thing (@{%mylist}{$key}){ foreach my $it (@$thing) { print "$min\n"; print "$max\n"; print "$it\n"; print "$key\n"; print "$thing\n"; print "@keys\n"; last; } } }
Okay "mon402.log" is the file I'm trying to pattern match in. I left the "$" out at the end of the pattern match line as it kept me from returning anything including errors, I'd just get my prompt again. Now if I leave it off I get the following errors
Argument "27-Jun-2001 00:23:59.37 D:19208797684 O:19209891234" isn't numeric or ge line 27 I think it's reading the whole line when it finds the time but it isn't even finding times in the time range I specify I'm lost. It will show all times with the error I listed just before. I think my pattern matching is wrong or the way I pushed the data off through the arrays and keys is screwed up.
The print statements at the bottom are just to see what prints out for the values given. Now here is the type of information in the "mon402.log".
27-Jun-2001 12:08:19.17 SendSMReq:T:1069 D:19203311338 O:Voice Mail M +WI P:0x20 C:0xe0 V:07-05 12:08 <20> 27-Jun-2001 12:08:19.36 SendSMCnf:AbsSub:1068 27-Jun-2001 12:08:19.56 SubmitInd:T:0 D:19207024720 O:19202928411 P:0 +x0 C:0x0 V:09-11 12:08 <yeah> 27-Jun-2001 12:08:20.05 SubmitInd:T:0 D:19207137406 O:19203314700 P:0 +x0 C:0x0 V:06-28 12:08 <LAST GF WAS 19 WAY TO IMMATURE, SUCKED IN BED +> 27-Jun-2001 12:08:20.30 SendSMReq:T:1070 D:16083089587 O:16083089560 +P:0x20 C:0x0 V:07-05 11:02 <good morning sleepy head> 27-Jun-2001 12:08:20.31 SubmitRsp:0 27-Jun-2001 12:08:20.32 SubmitRsp:0 27-Jun-2001 12:08:21.62 SendSMCnf:StatOK:1065 27-Jun-2001 12:08:22.36 SendSMCnf:StatOK:1060 27-Jun-2001 12:08:22.56 SendSMCnf:StatOK:1063
Now what I need is for the script to be able to match a time range on the second field right after the date. So when I give it a range such as -
10:38:38.42-10:39:39.42

I want the script to print the first 3 fields of each line inbetween the time I specified from STDIN. I looked on the web and in books for days but I can't seem to find an example of pattern matching internal to a file. External I can do but I've never done internal matching before and I'm not that good at regular expressions atleast the ones as complex as I need mine to be in order to search the way I want.

The brassmonk,
I relish the answer to this problem

Edit: chipmunk 2001-07-09


In reply to pattern match or key problem 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.