in reply to Mass file search prob
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:
At which point I'd do some basic checking (eg make sure "010231" wasn't entered as a date...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; }
Search now is easy.. once you have a list of files, or a way to get the list of files one by one...
Of course, this is all untested code, and it may not match exactly how you are setting up your file.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; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Mass file search prob
by brassmon_k (Sexton) on Apr 04, 2001 at 22:19 UTC | |
by brassmon_k (Sexton) on Apr 10, 2001 at 17:56 UTC |