On Mon, May 13, 2002 at 10:37:50PM +0900, Berger, Daniel wrote:
> 
> I'm looking for a way to modify a file inline without using a temp file.  I
> want to do this within code, not on the command line (and no, I'm not
> interested in 'system' calls either).
> 
> All I'm really trying to do is a unix2dos type operation.  Easy enough with
> temp files, I realize, but I'm stubborn. :)

I never did it in Ruby, but if the feature is implemented similar to
Perl, than something along this lines should work:

  def unix2dos(filename)
  argv=ARGV
  ARGV=[filename]
  $-i = ".bak"

  while gets
     gsub(/\n/,"\r\n");   # Or is Newline on Dos \n\r?
  end

  ARGV=argv
  end

Maybe it works. :-)

I also do not know how to revert the effect of setting $-i. By setting
it to nil?

-- 
marko schulz