From: ts Date: 2001-03-03T02:59:59+09:00 Subject: [ruby-talk:11911] Re: rewrite with Ruby >>>>> "H" == Hugh Sasse Staff Elec Eng writes: H> How would one make it really generic? Ruby has -i as well, so how can one H> get at it to do: H> ruby -i.bak -p -e 'gsub(/^#define DEBUG/, "#undef DEBUG/") config.h H> in an elegant way, within a program? First you copy the file, then you write : pigeon% cat aa 123 abc pigeon% pigeon% cat b.rb #!/usr/bin/ruby require "mmap" m = Mmap.new("aa", "rw") m.gsub!(/./, '(\&)') pigeon% pigeon% b.rb pigeon% cat aa (1)(2)(3) (a)(b)(c) pigeon% it's really experimental actually and it define only bang methods (gsub() is not defined) to don't return a string too big. it's also slow, well it's best to not modify the file :-) Guy Decoux