I need to write a script that opens a file and either:
1) deletes the last line and replaces it. or alternatively.
2) compares the last line and if it is not equal to what I need it to be then it replaces it. I think option 1 will be simpler, so I'm going with that. However, the line that I need to inset must have the file name in it. ie: File name ABCD Replaced Line: <xxxx.xxx.xxx.xxx, "xxx", xx_ABCD, xxx="">
so I open my file by:#Takes file name from command prompt #Then assigns the name to str fileName $fileName = INFILE; #open the file and copy to an array open(INFILE) || die("Cannot Open File"); @aFile = <INFILE>; close(INFILE); # How do I get the script to continue if line 6 is # already deleted? # Delete line 6 splice(@aFile,5) || die("Line 6 is already deleted");
This is where I am stuck. I need to append the end of the file with a long string (see example above) that includes the file name. How difficult would it be to implement a test of the last string and output if the change had been made or not? Any assistance would be greatly appreciated. Thanks in advance
In reply to Find and Replace by PyrexKidd
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |