If the intent of your example is to catch everything between "Oct 10 05:50:00" and "Oct 10 05:52:59" inclusive, then a logical two-arg, start/end spec would look like this (which would be pretty simple for any naive user to understand):
(Including specific seconds values in the start and/or end options would also be simple.)script.pl --start 'Oct 10 05:50 --end 'Oct 10 05:52'
Depending on what kind of data the script is going to do its "binary search" over, it might be more sensible to use one of the Date:: modules, to interpret both the user's ARGV values and the date values in the data being searched - i.e. something like:
The "get_secs_from_*" functions would just invoke some suitable Date:: module to return "unix_time" (or whatever term is used for "seconds since the epoch" in the chosen module).my $user_start_date = get_secs_from_opt( $opt{start} ); my $user_end_date = get_secs_from_opt( $opt{end} ); for my $record ( @data_records ) { my $rec_date = get_secs_from_data( $record ); if ( $rec_date >= $user_start_date and $rec_date <= $user_end_date + ) { # do something with a hit... } }
But then, I'm not sure what you mean by "binary search", so maybe this isn't helpful.
In reply to Re: dynamic regex
by graff
in thread dynamic regex
by mhearse
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |