From: nobu.nokada@... Date: 2002-08-23T11:18:38+09:00 Subject: Re: Can I write to DATA? Hi, At Fri, 23 Aug 2002 05:44:07 +0900, GOTO Kentaro wrote: > > How would I modify the text below __END__? > > > > ----- begin file --- > > # code to modify text below > > __END__ > > change me > > ---- end file--- > > You mean like this? > > f = open(__FILE__, "r+") > if /(.*?^__END__$.*?)(^.+)/m =~ f.read > script_size = $1.size > f.pos = script_size > f.truncate(script_size) > f << $2.gsub(/^/, "> ") + "hello?\n" > end > f.close > __END__ > hello? This fails for a script contains __END__ inside string. I recommend: script_size = __DATA__.pos And under Windows, I guess you need to close __DATA__ before reopen __FILE__. -- Nobu Nakada