Hi All,
I basically wanted some tips from you to search a particular string entirely and replace the same with a new string, in an Email directive file. The help I get from Goggle search is not very relevant to what I am trying to do. I am pasting the code below for the file operation.
open(INPUT, ">>$mail_driver/$emailadd")|| die "can't open File";
# I don't want to overwrite the entire existing file.. So append mode
while (<INPUT>) {
print "Entered the While loop";
if (/$module1/i) {
print INPUT "$module1";
print INPUT " ";
print INPUT "$lab1";
print INPUT " ";
print INPUT "$production1";
print INPUT " ";
print INPUT "$laudit1";
print INPUT " ";
print INPUT "$paudit1\n";
}
}
close INPUT;
$module1 holds the value I want to search for, and replace the entire line with the new string. It would typically be like
WES518 lab production laudit ….before replacement,
I want to replace this with say,
WES518 lab laudit (based on the inputs from user…remember The original string will not exist anymore)
Is there a straightforward way of doing it (say.. go to that line in the file and replace this old-string with new one), or should I be reading the entire file into an array, replace the string in an array and write this entire array back to same file..?
Any suggestions or links would be greatly appreciated.
Thanks,
Subbu
_______________________________________________ Perl-Unix-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs