Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: dynamic regex

by Kenosis (Priest)
on Dec 04, 2012 at 03:59 UTC ( #1006989=note: print w/ replies, xml ) Need Help??

in reply to dynamic regex

I agree with graff about using a Date:: module. How would you create the end given this start? --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 );


$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.

Comment on Re: dynamic regex
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1006989]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2015-12-01 21:10 GMT
Find Nodes?
    Voting Booth?

    My keyboard shows this many letters:

    Results (27 votes), past polls