in reply to Convert time string to seconds
perl -le '@times=qw(5:29,11 29,11 29 ,11 5:29 abc); foreach my $time (@times){ if($time!~/[0-9:,]+/) {$seconds=-1} else { ($seconds=$time)=~s{^(?:(\d+):)?(\d+)?(?:,(\d+))?$}{$1*60+$2+$3 +/10**2}e;} print $seconds}' 329.11 29.11 29 0.11 329 -1
|
|---|