[PBML] Re: Search and replacing text in a file
- On Thu, 08 Oct 1998 14:02:29 -0700, webprogramming <info@...>
>I need to search and replace a certain word in a text file from a webformSomething like this:
>submission. The user would enter a word (in this case a domain name) in an
>input box on a webform, and submit; the script would grab the text file ,
>search for the word "template", and replace it with the domain name entered
>by the user, save the file with a new name (domain_name.db) and close it. I
>think I can do this with a while (<>) diamond operator , and a substitution
>command. What would be the easiest way to do this.
use CGI ':standard';
$word = param('word');
open(FOO,'<file.ext') || die;
open(BAR,'>newfile.ext') || die;
This is just a skeleton, without much error checking or chrome, but it should
get you started.
jboes@... UIN 3394914 (ICQ: www.mirabilis.com)
DBA/Developer/Web Engineer for hire
"Sucking up bandwidth since 1994."
For easy online travel reservations, go to Internet Travel Network:
Subscribe, unsubscribe, opt for a daily digest, or start a new e-group
at http://www.eGroups.com -- Free Web-based e-mail groups.