my $time = "01:00:01.004"; my ($no_ms) = $time =~ /([\d:]+)/; #any digit or colon print "no milliseconds = $no_ms\n"; no milliseconds = 01:00:01