note
Kenosis
<p>I agree with [http://perlmonks.org/index.pl?node_id=44715|graff] about using a <c>Date::</c> module. How would you create the <c>end</c> given this <c>start</c>?</p>
<c>
script.pl --start 'Dec 31 23:59'
</c>
<p>Consider the following:</p>
<c>
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 );
</c>
<p>Output:</p>
<c>
$startSeconds: 1357027140; $endSeconds: 1357027260; Delta: 120
</c>
<p>You can use [http://search.cpan.org/~gbarr/TimeDate-1.20/lib/Date/Parse.pm|Date::Parse] to convert a line's date/time string to seconds, and then print the line if the value's within the <c>$startSeconds</c> and <c>$endSeconds</c> range.</p>
1006963
1006963