use strict; my $seconds = 0; my $timestr = '5H3M17S'; my ($hr,$min,$sec) = $timestr =~ /^(?:(\d+)H)?(?:(\d)+M)?(\d+)S$/; $seconds += $hr * 60 * 60 if defined $hr; $seconds += $min * 60 if defined $min; $seconds += $sec; print "seconds left to going live - $seconds";