#!/usr/bin/ruby -w # Given two filenames specified on the command line, replace the whitespace # characters from the first file with the corresponding characters from # the second file. if ARGV.size != 2 print "#{$0} {layer1.txt} {layer2.txt}\n" exit 1 end data1 = nil data2 = nil File.open(ARGV[0], "r") {|f| data1 = f.read} File.open(ARGV[1], "r") {|f| data2 = f.read} if data1.size != data2.size print "File sizes are not equal: #{data1.size} vs #{data2.size}\n" exit 1 end space = /\s/ data1.chars.zip(data2.chars).each{|p| print p[space.match?(p[0]) ? 1 : 0] }