So simple to do with minimal prerequisites (one core module, Time::Local):
use Time::Local qw< timegm >;
while( <> ) {
my @when = split /,\s*/, $_;
for( @when ) {
my @parts = /([0-9]+)/g;
$_ = timegm( reverse( $parts[0]-1900, $parts[1]-1, @parts[2..5
+] ) );
$_ += "0.$parts[6]";
}
print $when[0] - $when[1], $/;
}
__END__
2017-01-09 05:08:04.575804, 2017-01-09 05:08:04.319338
2017-01-09 05:08:17.093719, 2017-01-09 05:08:16.840292
2017-01-09 05:12:48.629407, 2017-01-09 05:12:48.372687
2017-01-09 05:13:25.315665, 2017-01-09 05:13:25.061834
2017-01-09 05:14:08.171994, 2017-01-09 05:14:07.916187
2017-01-09 05:17:03.182747, 2017-01-09 05:17:02.929309
2017-01-09 05:18:46.561289, 2017-01-09 05:18:46.305743
2017-01-09 05:19:09.772227, 2017-01-09 05:19:09.518975
__END__
0.256465911865234
0.253427028656006
0.256719827651978
0.253830909729004
0.255806922912598
0.253437995910645
0.255546092987061
0.253252029418945
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|