in reply to Matching dot using regexp

Another way to do this is with "match global". In this case, we say essentially "give me the sequences of digits found". What separates the digit sequences (i.e. numbers) doesn't matter. non-digit stuff gets skipped. This is a case of specifying what we want instead of specifying and splitting upon what we don't want.
#!/volume/perl/bin/perl use warnings; use strict; use DateTime::Duration; my $time = "01:00:01.004"; my @output_list = $time =~ /(\d+)/g; print "@output_list\n"; # 01 00 01 004
Update: Also, often in Perl, it is advantageous to assign meaningful names to components of a split or match global. It is rare to see something like $output_list[3] in my Perl code because the reader has to know what the heck the value at index 3 means.
#!/volume/perl/bin/perl use warnings; use strict; use DateTime::Duration; my $time = "01:00:01.004"; my ($hour,$min,$sec,$ms) = $time =~ /(\d+)/g; print "hour=$hour\n", "minutes=$min\n", "seconds=$sec\n", "milliseconds=$ms\n"; __END__ hour=01 minutes=00 seconds=01 milliseconds=004
Update again:
another possibility if the intent is to "delete the milliseconds"
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
There are many variations upon this theme. I think the above is more clear, but...
my $time = "01:00:01.004"; $time =~ s/\.\d+$//; #explictly delete the ending milli_seconds print "time stripped ms = $time\n"; #time stripped ms = 01:00:01