From: Leslie Viljoen Date: 2006-10-03T06:59:53+09:00 Subject: Email embedding Hello! Seeing the XML-like format one of the quiz posters used for sending in his program, I wrote two programs that can embed and extract multiple files from an email. I'll include the programs in their own format so you can understand ;-) Someone may have already done something like this, but if not, here you go. I know of one problem - the uncruncher adds a blank line at the end of the files it extracts, so someone might want to fix that. #/usr/bin/env ruby # email_crunch # usage: email_crunch.rb *.rb > crunchfile.txt puts "" ARGV.each do |f| next if FileTest.directory?(f) puts "" puts File.new(f).read puts "" end puts "" #/usr/bin/env ruby # email_uncrunch # usage: cat crunch_file | email_uncrunch.rb # or : email_uncrunch.rb crunch_file require 'breakpoint' if ARGV.length != 0 text = File.new(ARGV[0]).read else text = $stdin.read end text =~ /(.*)<\/code>/m code = $1 filename = "" f = nil code.each_line do |line| line.chomp! if line =~ /^$/ filename = $1 puts "Creating #{filename}" f = File.new(filename, "w") elsif !filename.empty? if line == "" f.close filename = "" else f.puts(line) end end end - Les