From: Dossy Date: 2002-06-12T23:31:25+09:00 Subject: Re: How to reset a variable to the value in another variable? On 2002.06.12, Kurt Euler wrote: > All- > > In line 8 in the code below, I want to reset the string variable "content2" with the value in string variable "intro". However, what I'm finding is that line 8 sets up "content2" as some type of pointer to "intro": The content2.gsub commands I'm making in lines 9 through 12 are affecting the value > of "intro" as if I were doing "intro.gsub" commands. > > The solution has got to be simple, but it it illudes me. Your help appreciated! Thanks! -k euler > > 01 intro = '' > 02 File.open("./input/intro_subtemplate.txt") { |f| intro = f.read } > 03 > 04 content = File.new("./input/main_readme_template.txt").read > 05 > 06 IO.foreach("./input/packages.txt") { |x| > 07 field = x.chop.split('\t') > 08 content2 = intro 08 content2 = intro.dup > 09 content2.gsub!(//, intro) > 10 content2.gsub!(//, field[2]) > 11 content2.gsub!(//, field[1]) > 12 content2.gsub!(//, field[3]) > 13 File.open("./output/#{field[0]}", "w+") { |file| file.write(content2) } > 14 } -- Dossy -- Dossy Shiobara mail: dossy@panoptic.com Panoptic Computer Network web: http://www.panoptic.com/ "He realized the fastest way to change is to laugh at your own folly -- then you can let go and quickly move on." (p. 70)