my ( $quote, $time ) = m{ \A # beginning of line ( # begin capture \d+ # digits before decimal \. # decimal point \d{3} # three digits after decimal ) # end capture [^,]* # optional non-comma stuff \s* , \s* # comma with optional spaces ( # open capture \d\d? # hours : \d\d # minutes : \d\d # seconds ) }xms;