Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #4210

Re: gsub and multiple-replacement

From 7stud -- <bbxx789_05ss@yahoo.com>
Newsgroups comp.lang.ruby
Subject Re: gsub and multiple-replacement
Date 2011-05-10 16:25 -0500
Organization Service de news de lacave.net
Message-ID <c6da27b88a381128e0c603bd0fb1c642@ruby-forum.com> (permalink)
References <eb286679b6d688c796525a6786d4394f@ruby-forum.com>

Show all headers | View raw


> Here are a few caveats:
> I don't need a temp file.

Yes, you do.

> I am unconcerned with overwriting the username.txt file with itself.

Ok, you still need a tempfile.

Now, if you say you are unconcerned with losing all the data in your 
file, then you don't need a tempfile.

The bottom line is this: you don't replace anything in a file.  Instead, 
you read in the original file, and write out the altered lines to a new 
file.  When you are done, you can delete the original file and rename 
the new file to the old file name.

-- 
Posted via http://www.ruby-forum.com/.

Back to comp.lang.ruby | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

gsub and multiple-replacement Greg Hacke <greghacke@gmail.com> - 2011-05-10 16:16 -0500
  Re: gsub and multiple-replacement 7stud -- <bbxx789_05ss@yahoo.com> - 2011-05-10 16:25 -0500
  Re: gsub and multiple-replacement 7stud -- <bbxx789_05ss@yahoo.com> - 2011-05-10 16:43 -0500
    Re: gsub and multiple-replacement Greg Hacke <greghacke@gmail.com> - 2011-05-10 19:49 -0500
      Re: gsub and multiple-replacement 7stud -- <bbxx789_05ss@yahoo.com> - 2011-05-10 21:07 -0500
      Re: gsub and multiple-replacement Jesús Gabriel y Galán <jgabrielygalan@gmail.com> - 2011-05-11 03:00 -0500
  Re: gsub and multiple-replacement Phillip Gawlowski <cmdjackryan@googlemail.com> - 2011-05-10 16:28 -0500
  Re: gsub and multiple-replacement Greg Hacke <greghacke@gmail.com> - 2011-05-11 08:45 -0500
    Re: gsub and multiple-replacement Jesús Gabriel y Galán <jgabrielygalan@gmail.com> - 2011-05-11 10:01 -0500
  Re: gsub and multiple-replacement 7stud -- <bbxx789_05ss@yahoo.com> - 2011-05-11 18:31 -0500
  Re: gsub and multiple-replacement 7stud -- <bbxx789_05ss@yahoo.com> - 2011-05-11 18:59 -0500

csiph-web