My solution only acts on one 'line' at a time, by calling enumerating
over the content. However, if you pass in an array with multiple lines
in each index, it can use that too. Matches are based on the punctuation
structure and word count of the lines. This works really well for the
example given, but may not in other situations.

http://members.iinet.net.au/~soxbox/ruby_quiz_53/dryer.rb
http://members.iinet.net.au/~soxbox/ruby_quiz_53/array_sync_enum.rb

The lambda names in the output all suck completely which always makes
the output longer than the input, but I don't have the time to make them
prettier. It would be easy enough to do a find/replace on the lambda
names to make something more useful. I've tried as much as possible to
ensure that the generated output will match the generated input exactly.

It runs in O(n!) time in regards to line length, so putting an essay
through this would take FOREVER. I would have been better off not using
the "generate every regex that matches this line" approach - but I
neglected to throw anything with a decent line-length at it until late
in the piece, and then I couldn't be bothered changing it. Just getting
a list of tokens for each line and then matching up the lines with the
most matching tokens would have sufficed. Doofus.

Here's the output generated for the quiz sample input.

%CREATE_TABLE_ = lambda do |arg0|
%    "CREATE TABLE `"+arg0+"` ("
%end
%_id_int_11_NOT_NULL_auto_increment_ = lambda do ||
%    "`id` int(11) NOT NULL auto_increment,"
%end
%_varchar_NOT_NULL_default_ = lambda do |arg0,arg1|
%    "`"+arg0+"` varchar("+arg1+") NOT NULL default '',"
%end
%_description_text_NOT_NULL_ = lambda do ||
%    "`description` text NOT NULL,"
%end
%PRIMARY_KEY_id_ = lambda do ||
%    "PRIMARY KEY  (`id`)"
%end
%_TYPE_MyISAM_AUTO_INCREMENT_ = lambda do |arg0|
%    ") TYPE=MyISAM AUTO_INCREMENT="+arg0+" ;"
%end
%_int_11_NOT_NULL_default_0_ = lambda do |arg0|
%    "`"+arg0+"` int(11) NOT NULL default '0',"
%end
	<%=CREATE_TABLE_["authors"]%>
	  <%=_id_int_11_NOT_NULL_auto_increment_[]%>
	  <%=_varchar_NOT_NULL_default_["firstname","50"]%>
	  <%=_varchar_NOT_NULL_default_["name","50"]%>
	  <%=_varchar_NOT_NULL_default_["nickname","50"]%>
	  <%=_varchar_NOT_NULL_default_["contact","50"]%>
	  <%=_varchar_NOT_NULL_default_["password","50"]%>
	  <%=_description_text_NOT_NULL_[]%>
	  <%=PRIMARY_KEY_id_[]%>
	<%=_TYPE_MyISAM_AUTO_INCREMENT_["3"]%>
  
	<%=CREATE_TABLE_["categories"]%>
	  <%=_id_int_11_NOT_NULL_auto_increment_[]%>
	  <%=_varchar_NOT_NULL_default_["name","20"]%>
	  <%=_varchar_NOT_NULL_default_["description","70"]%>
	  <%=PRIMARY_KEY_id_[]%>
	<%=_TYPE_MyISAM_AUTO_INCREMENT_["3"]%>
  
	<%=CREATE_TABLE_["categories_documents"]%>
	  <%=_int_11_NOT_NULL_default_0_["category_id"]%>
	  <%=_int_11_NOT_NULL_default_0_["document_id"]%>
	) TYPE=MyISAM ;
  
	<%=CREATE_TABLE_["documents"]%>
	  <%=_id_int_11_NOT_NULL_auto_increment_[]%>
	  <%=_varchar_NOT_NULL_default_["title","50"]%>
	  <%=_description_text_NOT_NULL_[]%>
	  <%=_int_11_NOT_NULL_default_0_["author_id"]%>
	  `date` date NOT NULL default '0000-00-00',
	  <%=_varchar_NOT_NULL_default_["filename","50"]%>
	  PRIMARY KEY  (`id`),
	  KEY `document` (`title`)
	<%=_TYPE_MyISAM_AUTO_INCREMENT_["14"]%>
#####################################################################################
This email has been scanned by MailMarshal, an email content filter.
#####################################################################################