Monks

I need your enlightenment

I have a simple perl script (I am a Novice)Actually there are 2 scripts exactly the same except for a field change in one of them. The scripts are designed to search through a directory with call trace files and based off their search field pull the relevant data for a date or time range I give them. An example of what all the call trace files look like is given immediately below.

TTFILE03.4892010203135698

First field TTFILE03 is always the same - Second field (4892) for numbers which are sequential(date)(6 digits) then (time)(six digits)<--24hour clock

I have the date and time search scripts working but wish to narrow down the results of the search as it takes a while to decode the TTFILES and do all the other fun stuff before you pull a searched cell phone number out of them.

Anywho the problem is this:

The PERL script searches through the current directory for date or time whichever script I use the date or time script and then it takes the TTFILES and puts the name(Not the actual file) into a new file. At any time the TTFILE directory only contains 30 days worth of calltrace records Now when I do a date search no worries it's cool.

However the time search is dissapointing...Yet it will have it's purpose somewhere. It will pull data for all 30 days inbetween the time range I specify However I hate that and I want the time search script to perform this idea but I don't know how to tell my perl script the following. In order to narrow the time search I need to have the script first know what the date is without pulling any data and then recieve the time range but only pull the data once it knows what the date and time are and only pull the time range for the dates given and not all 30 days.

Right now here is what happens the date range works just fine. I tell it a range in this format YYMMDD-YYMMDD and it looks up the range However the time script searches HHMMSS-HHMMSS and I don't know how to tell it not to search all 30 days. I want to tell it okay this time range 135467-175467 on this date 010318-010318 only or on these days only 010318-010322.

That's my problem. Here's the script.

#! /usr/bin/perl -w use strict; my %mylist; my $min; my $max; my $range; my $line; #Get the range and enter data in this format with no spaces YYMMDD-YYM +MDD $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+$//; chomp(@ARGV = <STDIN>) unless @ARGV; for (@ARGV) { if ($_=~ m/(\w+)\.(\d+)\.(\d+)\.(\d+)$/) { #push the restricted range of filenames onto a hash of arrays keyed on + the #data field if (($3>= $min) && ($3 <= $max)) { #$3 is date field, $4 is time field + push(@{$mylist{$3}}, $_); } } } my @keys = sort (keys %mylist); foreach my $key (@keys) { foreach my $thing (@{%mylist}{$key}){ foreach my $it (@thing) { print "$it\n"; } } }
I appreciate any divine knowledge which you may pass on to me! The Brass Monk

In reply to Mass file search prob 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.