Jun 17, 2010, 10:41 AM
Post #1 of 2
I want to write a perl script that appends "My_File.txt" with a "string" when the script is run for the very first time.
Script to append a file only once and return error on subsequent run
Subsequently if I run this script again, I shud get a message that "string" is already appended in "My_File.txt".
I've written a code, but it is not giving the desired result. Pls let me know the issue with this script and suggest a relevent solution for the same..
open($My_File_FP,"<$My_File") || die("This file will not open!");
print " found $Target on line $. \n";
open($My_File_FP,">>$My_File") || die("This file will not open!");
print $My_File_FP "\n ADD_STRING_HERE \n";
Pls let e kno the issue... I'm a newbie in Perl and want to lear more thru this forum..
Thanks in advance!