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