Replace a String in a File with an other String both in variables 
Author Message
 Replace a String in a File with an other String both in variables

I want to replace a string in a text-file with an other string. The Search-
and Replace-String are both stored in a variable. I wanth to replace every
Search-String in the whole file.


$SearchString = "asdf";
$ReplaceString = "TEST";

open(WRITE,"> file_new.txt");

while (defined($input =<READ>))

 $input =~ s/$SearchString/$ReplaceString/g;
 print WRITE $input;



This Program does not work like i want i to work ?!

Where ist the Problem?

Sat, 26 Jun 2004 16:37:23 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Q: How to replace string with variable ?

2. direct replacing of string in file

3. Using perl to replace string in binary file???

4. Replacing string in binary file

5. Newbie question: replacing strings in large binary files?

6. Replacing a string in a file

7. Searching and replacing strings in a file

8. How to replace these strings in file.htm

9. find and replace a string in a huge file

10. string replace in files within subdirectories

11. searching many text files sequentially for strings and replacing

12. Replacing a string in several files.


Powered by phpBB® Forum Software