Im working on some programs to help me w/ running, producing graphs etc... I need to convert time to seconds, do some simple math, then convert back to a hh::mm::ss format. Im using DateTime::Precise to convert back, im just curious and have been unable to find a way myself if there is a better way? ie pure Perl. This just *seems* clunky.
<br><br>#!/usr/bin/perl<br><br>use strict;<br>use warnings;<br>use DateTime::Precise ;<br><br>my ( $hour, $min, $sec, undef ) = split/:/, $ARGV[0];<br><br>$hour = $hour * 3600;<br>$min&nbsp; = $min&nbsp; * 60;<br><br>my $seconds = $hour + $min + $sec;
<br><br>my $distance = $ARGV[1];<br><br>print &quot;seconds = $seconds\n&quot;;<br><br>my $t1 = DateTime::Precise-&gt;new($seconds / $distance);<br><br>my $pace = $t1-&gt;strftime(&#39;%T&#39;);<br><br>$pace =~ s/^00://;<br>
<br>print&nbsp; &quot;Pace is $pace\n&quot;;<br><br>sub usage<br>{<br>&nbsp;&nbsp;&nbsp; print &quot;$0 time dist\n&quot;;<br>&nbsp;&nbsp;&nbsp; print &quot;&nbsp; eg $0 01:54:18 13.1\n&quot;;<br>&nbsp;&nbsp;&nbsp; exit 1;<br>}<br clear="all"><br>Ted<br>-- <br>If you mess with a thing long enough, it&#39;ll break.
<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-- Schmidt