in reply to perl time conversion
I could always multiply the first number by 60x60...
Well hey, why not?
sub seconds { if( $_[0] =~ /^(\d+):(\d+):(\d+)$/ ) { return ($1 * 60 + $2) * 60 + $3; } else { return 0; } }
Look how much time you just saved :) Or is there a deeper issue involved?
update: looking at jeffa's solution underscores what I mean. Not that his solution is bad, but you have to spend the time to find, download and install the module. Then you have to memorise the % parameters. Each time I need to use strfptime, I'll have to call up the man page. For simple uses like this, that's going to be a net loss.
There's Lazy and Lazy, and I'm not sure that the module approach is a win here. Doing what you did saved you the most time, and let you get on with the rest. It's much faster to bang out the above code (although one should not underestimate the fact that the module should have regression tests that cover what you're using it for).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: perl time conversion (seconds)
by markd (Acolyte) on Nov 26, 2003 at 16:29 UTC |