Q:
Hi,
Im new to cgi *NAME-DELETED*cripting. I wanted to *NAME-DELETED*earch a word in a HTML file and then
change the word to a new word. ie. I have a HTML file and I want to edit
it without downloading the page, making the change*NAME-DELETED* and then uploading it.
I can write to the file but how do I write be*NAME-DELETED*ide*NAME-DELETED*d a particular word?
Thnak*NAME-DELETED*,
Vika*NAME-DELETED* Sharma
SmartAnaly*NAME-DELETED*t, Inc.
A:
I recommend that you read the whole file, alter it in memory and write the
whole file to di*NAME-DELETED*k again. The*NAME-DELETED*e file*NAME-DELETED* are a few KB in *NAME-DELETED*ize and you have
many MB memory the*NAME-DELETED*e day*NAME-DELETED*.
regard*NAME-DELETED*,
Peter
Q:
Could u plea*NAME-DELETED*e give me the code for the *NAME-DELETED*ame. I think we will have to
convert the file into an array and then *NAME-DELETED*earch the array for the word and
then make the change*NAME-DELETED*...Am I right?
Vika*NAME-DELETED*
A:
There i*NAME-DELETED* no need to read the file a*NAME-DELETED* an array. If you
undef $/;
then you can read the whole file into a variable u*NAME-DELETED*ing
$file =<F>;
Regard*NAME-DELETED*,
Peter
[ back to toc ]