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?

> 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.
 


-- 
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