in reply to Mass file search prob

I think you're losing us on the logic of what you'll input into the programs. Search for files is trival for your case. Let me extrapolate from what you've stated:

The program will be given two parameters: a time range and a date or date range or the current date, if not specified. You want a list of all files that are within that time range on those dates (or solitary date).

Input parsing isn't that hard:

my $times = $ARGV[1]; my ($start_time, $end_time) = ( $times =~ /^(\d{6})-(\d{6})$/ ) or die + "Time values are not in correct form\n"; my $dates = $ARGV[2] || strftime ("%y%m%d", localtime); # make sure to use POSIX qw(strfti +me); my $start_date, $end_date; if ( ! (($start_date, $end_date) = ( $dates =~ /^(\d{6})-(\d{6})$/ ) ) + ) { ( $start_date ) = ( $dates =~ /^(\d{6})$/ ) or die "Date values not + in correct form"; $end_date = $start_date; }
At which point I'd do some basic checking (eg make sure "010231" wasn't entered as a date...

Search now is easy.. once you have a list of files, or a way to get the list of files one by one...

my @matched; foreach $file ( @filelist ) { # or a while loop... my ( $fdate, $ftime ) = ( $file =~ /(\d{6})(\d{6})$/ ); if ( ( $fdate >= $start_date ) && ( $fdate <= $end_date ) && ( $ftime >= $start_time ) && ( $ftime <= $end_time) ) { push @matched, $file; } }
Of course, this is all untested code, and it may not match exactly how you are setting up your file.
Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain

Replies are listed 'Best First'.
Re: Re: Mass file search prob
by brassmon_k (Sexton) on Apr 04, 2001 at 22:19 UTC
    First off you're very good at this - Second however take in the fact that I'm a beginner on PERL. Of course Input Parsing is easy for someone with a Phd and the Doctors title. I'm not being nasty I'm just saying it isn't easy for me. However I think I understand what you're doing. I don't understand the first reply though because the individual states $datemin and $datetime those have to be defined somewhere and I don't have a clue on how to do this....I was hired at a starting position and all I've ever programmed are shell scripts (Which I'm very good at) but the company I work for went to PERL (Can't blame em) So I'm learning PERL and it's quite different it has so many things you can do with it. Talking to it is different than shell. So bear with me please.

    The Brass Monk
      I found my own answer. All I had to do was add a datemin and datemax along with a timemin and timemax under my list and I had to create a second range because "split" can only handle 2 variables and didn't want 4 so I had to give it a time search and a date search and I also took out trailing and leading spaces with date/min,max and time/min,max. Finally in the if statement before the data gets pushed onto the keys I added $4 onto the $3 gt and le statements basically by doing it again and for the push statement that still remains $3 as it is keyed on date to weed out the time.

      The BrassMonk