@res =$_ =~/(\d{4}-\d\d-\d\d)/g # gets them all but also from lines without 'dates processed' @res = $_ =~/(\d{4}-\d\d-\d\d).*dates processed: (\d{4}-\d\d-\d\d,? ?)*/g # only returns first of trailing list @res = $_ =~/(\d{4}-\d\d-\d\d).*dates processed: ((\d{4}-\d\d-\d\d)*)/ # gets the right number of results but the final list all the same value!