in reply to dynamic regex
I agree with graff about using a Date:: module. How would you create the end given this start?
script.pl --start 'Dec 31 23:59'
Consider the following:
use strict; use warnings; use Date::Parse; use Date::Calc qw/Localtime/; my $startDateTime = 'Dec 31 23:59:'; my $addMinutes = 2; my $year = ( Localtime(time) )[0]; $startDateTime .= '00 ' . $year; my $startSeconds = str2time($startDateTime); my $endSeconds = $startSeconds + $addMinutes * 60; print "\$startSeconds: $startSeconds; \$endSeconds: $endSeconds; Delta +: " . ( $endSeconds - $startSeconds );
Output:
$startSeconds: 1357027140; $endSeconds: 1357027260; Delta: 120
You can use Date::Parse to convert a line's date/time string to seconds, and then print the line if the value's within the $startSeconds and $endSeconds range.
In Section
Seekers of Perl Wisdom