in reply to Automatically generate regular expression from source data
I can't endorse this approach as a Good Idea™, but you may want to take a look at Regexp::Assemble if you insist on a regex-based solution.
HTH,