in reply to Re: Time to seconds
in thread Time to seconds

If you also want to test for validity, you might want to replace the regexp search
$timestr =~ /^(?:(\d+)H)?(?:(\d)+M)?(\d+)S$/;
with
$timestr =~ /^(?:(?:(\d+)H)?(\d)+M)?(\d+)S$/;.

The difference is that the first will accept 10H5S, while the second won't. (And you'll be testing that the match succeeds in real code, of course).