P
Peter Bailey
Hello,
I'm trying to create a simple editing template for myself, just some
code that I can use for future editing needs, where I open a file,
change stuff, and then save the file. I created this simple little
script, but, it doesn't work when I run it. It complains about line 3. I
get an exception with "wrong number of arguments (0 for 1)." But, when I
do this script, line for line, in IRB, I have no problems.
Dir.chdir("C:/documents and settings/pb4072/my documents/scripts/ruby")
contents = File.read{"test1.txt"}
#The file is just a bunch of repeated "The quick brown fox..." phrases.
contents.gsub!(/fox/, "horse")
File.open("test2.txt", "w") { |f| f.print contents }
Thanks,
Peter
I'm trying to create a simple editing template for myself, just some
code that I can use for future editing needs, where I open a file,
change stuff, and then save the file. I created this simple little
script, but, it doesn't work when I run it. It complains about line 3. I
get an exception with "wrong number of arguments (0 for 1)." But, when I
do this script, line for line, in IRB, I have no problems.
Dir.chdir("C:/documents and settings/pb4072/my documents/scripts/ruby")
contents = File.read{"test1.txt"}
#The file is just a bunch of repeated "The quick brown fox..." phrases.
contents.gsub!(/fox/, "horse")
File.open("test2.txt", "w") { |f| f.print contents }
Thanks,
Peter