web design and hosting
features and pricing my account customer support about ICG Link, Inc. contact ICG Link, Inc.

This script allows users to edit lines in their data files using search criteria. When used in combination with the search and form scripts, you can use this script to edit content you manage from a back office administration area. Before you can use this script, you must set up a tab delimited data file. You can do this manually or it can be created using form.pl. More information on these files can also be found in search.pl. There are four steps required to make the script work:
  • Call the script;
  • Tell it which files to work with;
  • Tell it which records (lines) in the file will be changed;
  • Tell it which new values will replace the old values in the selected lines.
Call the script:
<form method=post action="/cgi-bin/replace.pl">

Which files to change:
This script assumes that the data files are tab delimited text files in the user's data directory and are named filename.data There are two ways to tell the script which files to use. If there is only one file, you may either put it in the script call:
<form method=post action="/cgi-bin/replace.pl/filename">
or in a form field:
<input type="hidden" name="f_file" value="filname">
If there are multiple files, you should call them using the form field method. (There is no limit to how many files you may change at once):
<input type="hidden" name="f_file" value="filname, anotherfile">

Which lines to change:
The script needs to know 2 things to find the lines in the datafile it is going to change.

a) Which columns are we looking in?
b) Which values are we looking for in those columns?


If you don't specify a column, the first column is used. Otherwise, you must tell the script using one of the following methods:
<input type="hidden" name="f_column" value="columnheading">
<input type="hidden" name="f_column" value="3">
*note: columns are numbered starting with 0, so 3 signifies the 4th column.


You must tell the script what value to look for in those columns when deciding which lines to change.
<input type="hidden" name="find" value="SearchStringHere">
<input type="hidden" name="f_column" value="Name, State"><br><input type="hidden" name="find" value="Amy Young, TN">

This tells the script that it should only make replacement in lines where the value under Name is "Amy Young" and the value under State is "TN".
Which new values to use:
Once the line is selected, you must tell the script which values within the line should be changed. This can be done by either specifying the column heading (i.e. City) or the column number starting with 0.
<input type="text" name="Name">
or if the fourth column had the Name field in it:
<input type="text" name="3">
Either entry would replace the value for the field Name on all lines that match the search criteria with whatever is typed in the input box. In real applications, it is often convenient to use the search script to deliver the current value from the data file so the user can see what it is and edit it as necessary. Then the replace script can change to the new entries. In such a case, the field above might actually look like this (see search.pl for more information):
<input type="text" name="Name" value="<! field=Name>">

After completing it's job, the script must be told where to go using a full URL:
<input type="hidden" name="f_success" value="http://www.yourdomain.com/done.html">

If a line has a partial match for the search stiring - for example, you are looking for 'Tim' under Name and the value on a line is 'Timothy Leary' - it, by default, is not considered a match. To turn on partial string matching, include the following line:
<input type="hidden" name="f_match" value="partial">
If you would like to delete the item, simply add another button like this:
<input type="submit" name="f_delete" value="Delete this item">
By default, the script will not allow users to enter html code and display the results in html format. It will simply replace the code (for example <b> will be replaced with <b>). If you would like html code to show up use:
<form method=post action="/cgi-bin/replace.pl?html">
<form method=post action="/cgi-bin/replace.pl/filename?html">
<form method=post action="/cgi-bin/replace.pl/companies">
<input type="hidden" name="find" value="ual23">
<input name="4">
<input name="6">
<input type="hidden" name="f_success" value="http://www.cnn.com">
<input type="submit" value="Update for Merger">
This will read /www/data/companies.data and look for any lines which contain "ual23" as their first value (when f_column is excluded, the default value is 0 - the first column). When it find a line that matches, it will replace the value of the 5th and 7th columns (name="4" & name="6") with whatever the user inputs. When it is done, it will go to CNN's homepage.

<form method=post action="/cgi-bin/replace.pl">
<input type="hidden" name="f_file" value="companies, contacts">
<input type="hidden" name="f_column" value="company_name, company_size">
<input type="hidden" name="find" value="USAir, large">
<input type="hidden" name="company_name" value="United Airlines">
<input type="hidden" name="3" value="UAL">
<input type="hidden" name="company_size" value="huge">
<input type="hidden" name="f_match" value="partial">
<input type="hidden" name="f_success" value="http://www.cnn.com">
<input type="submit" value="Update for Merger">
<input type="submit" name="f_delete" value="Delete this item">
This will search in /www/data/companies.data and /www/data/contacts.data for lines on which the value under "company_name" contains "USAir" AND "company_size" conatains "large".

When it finds a line that matches the above...it will replace the value under "company_name" with "United Airlines". It will replace the value under the fourth column (3 is the fourth, as it starts at 0) with "UAL". Finally, it will replace the value under "company_size" with "huge".

Now that it has done its job, it will go to the success page...in this case, the CNN homepage.
ICG Link, Inc. 7003 Chadwick Drive, Suite 111, Brentwood, TN 37027