|Problems? Is your data what you think it is?|
Re: Timeleft subroutineby kennethk (Abbot)
|on Aug 29, 2012 at 19:42 UTC||Need Help??|
When I have to do math, I use DateTime, which includes subtraction. If you want to do the math yourself, it is likely easier to keep it in epoch format, and then only convert for display.
Also note that, since you are not using lexical variables (declared with my) your values for $spareminute and $sparehour will leak between calls. You can fix this by just replacing the assignments w/ modifications of the original variables, a la: $minutes -= 1; and $hour -= 1;.
Finally, you have a one-off typo on your return value: you have $minute in place of $minutes in my $baas = $hour + $minute + $seconds;. This would have been caught by strict, and looks like a bug that happened during debugging.
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.