codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  How To write the content in a different file (i.e temp file)and then rename it to the original file name?  powerfulperl at 17:57 on Sunday, August 22, 2010
 

I have the following code, I need to write the content of a file.txt after searching

for line Local=IN, if found then its o.k if not found then enter the line Local=IN after

the line 'Testing Option OK'.

1. open FH, "/forum/ltfile.txt";
2. $/=undef; #set slurp mode
3. $file_contents=<FH>;
4. if (index($file_contents, "Local=IN")!=-1) { # file doesn't contain string
5. ($first, $second)=split(/Testion Option OK/, $file_contents);
6. $new_file=$first."\nTestion Option OK\nLocal=In\n".$second;
7.# write out the new file here
8. }
9. close FH;









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  How To write the content in a different file (i.e temp file)and then rename it to the original file name?
•  Enter data in the middle of a file after doing some pattern matching
•  CSS 3.0 Background Properties
•  Sign up to stay abreast on Open source
•  Re: Write text strings to Serial Port
•  Re: Save up to 80% on SSL Certificates, RapidSSL Certificate @ $ 11.00/yr.
•  Re: IsDate() in JavaScript?
•  Re: horizontal scroll bar for drop down list box
•  Sign Up Now!!To Learn Solr Search Development from the Experts


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2010