|The stupid question is the question not asked|
A regular expression that will work for (hh:)mm:ss [converting clock time to seconds]by aware74 (Initiate)
|on Apr 13, 2012 at 00:20 UTC||Need Help??|
aware74 has asked for the
wisdom of the Perl Monks concerning the following question:
I'm still pretty new to Perl, and I want to write a Perl script that will take the elapsed time that is returned by the command
/bin/ps -p $pid -o etime --no-headingand convert it into seconds.
Below is my first attempt at it. But my code currently assumes that there will always be an hour component, and there will not be. Can someone give me some pointers on how to modify the regular expression for time to accept input like "32:05" in addition to "11:32:05"?
Any additional suggestions that you may have to improve the quality, readability and maintainability of the code would be greatly appreciated.
Thanks in advance,