On Sun, Aug 25, 2002 at 08:56:57AM +0900, Joel VanderWerf wrote:
> Jim Freeze wrote:
> > On Sun, Aug 25, 2002 at 07:31:13AM +0900, Joel VanderWerf wrote:
> > 
> >>Here's an example of the data stream approach.
> >>
> >>require 'roof/datastream' # from Roof on RAA
> >>
> >>DataStream.open($0, "r+") do |data|
> >>   while line = data.gets and line != "__END__\n"
> >>     ## maybe you can do this by seeking to __DATA__.pos,
> >>     ## but that doesn't seem to work in Ruby 1.6.7
> >>   end
> > 
> > DATA.pos works on 1.6.7 unix.
> 
> But does it return the position relative to the start of the file or 
> relative to the __END__? It seems to be the latter, so I can't use 
> DATA.pos to skip to the data part. Nobu's post suggests that there is 
> also a __DATA__ in addition to DATA, but that doesn't seem to exist in 
> 1.6.7.
> 
It returns the position relative to the start of the file.
So, 
  File.open(__FILE__,"w") { |f|
    f.pos = DATA.pos
    f.puts "write over the data after __END__"
  }
will start writing on the lone following __END__.

-- 
Jim Freeze
If only I had something clever to say for my comment...
~