brassmon_k has asked for the wisdom of the Perl Monks concerning the following question:
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.
I appreciate any divine knowledge which you may pass on to me! The Brass Monk#! /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"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Mass file search prob
by Masem (Monsignor) on Apr 04, 2001 at 21:27 UTC | |
by brassmon_k (Sexton) on Apr 04, 2001 at 22:19 UTC | |
by brassmon_k (Sexton) on Apr 10, 2001 at 17:56 UTC | |
|
Re: Mass file search prob
by thabenksta (Pilgrim) on Apr 04, 2001 at 21:14 UTC | |
by brassmon_k (Sexton) on Apr 04, 2001 at 21:21 UTC | |
by brassmon_k (Sexton) on Apr 10, 2001 at 01:13 UTC |