Lets analyze your script: First it slurps the contents of FILE2 into memory which means the file pointer is at EOF (= End Of File). In the inner loop it tries to read a line from FILE2 (file pointer at EOF, so no go) and then tries to write that line directly after its original place in the same file! Also it tries to write into a file that is opened for reading.
What seems to be missing is a line where you open FILE2 for writing (somewhere after you have read its contents). Also the inner loop has to loop over @file2, not <FILE2>
In reply to Re: Read strings from a file, search and replace same string in another file.
by jethro
in thread Read strings from a file, search and replace same string in another file.
by premal
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |