my @records = split /,\s*(?=\d{2}\/\d{2}\/\d{4}\s\d{2}\:\d{2}\:\d{2}\s[AP]M)/, $string; foreach (@records) { my %hash = (Date => split /\,\s*/); insert_into_db(%hash); }