On Tue, 23 Nov 2004 09:44:00 -0500 (EST), Chris Devers wrote:

>On Tue, 23 Nov 2004, FlashMX wrote:
>
>> I'm trying to do this script on my own as suggested by someone in this
>> group.
>
>Glad to hear it :-)
>
>> I'm getting confused on the login.
>
>I don't see where the program or the problem description involves
>logging in to anything -- is that really what you meant, or do you mean
>some other concept


Doh...I meant to type "logic"

>
>> I need to open the orginal file (which I've done) and then do a grep 
>> to search and then replace some text but I need to output the results
>> to the same file (can this be done?).
>
>Well, one easy way to do that is to use a temp file:
>
> * open original file
> * find what you want in the file
> * output the results to the temp file
> * move the temp file over the original file
>
>There are other ways to go about this, but this framework is one of the
>easier approaches to the problem.
>
>You could also iterate over the file, deleting each line that doesn't
>match the pattern you want, but this would be a little more complicated
>to write (not bad, mind you, just a little less straightforward) and I'm
>not sure that it would be any better than the steps outlined above.

I would still need to keep the original file intact. Bascially just reading in 
a large file. Using GREP to search for a match like "0000" then replace that 
with "0000 1111” and then search for
“2222” and then replace that with “2222 3333” and then start the search over 
again at “0000”...and so on at the same time writing the results to (I guess) a 
temp file and then rename the temp
file to the original when completed.

Being new I just want to make sure all my steps are correct.


>
>
>--
>Chris Devers




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to