New meeting place

Mark A. Sharkey mark at
Thu Sep 2 01:51:06 CDT 1999

Speaking of code snippets, here's a couple that I use all
the time:

1.  This one takes all the parameters from your HTML form
input, and makes local variables of the same names inside
your script.  For example, suppose you have a form that the
user has to enter name, address, phone, and you name each of
the form text fields 'name', 'address', 'phone'.  When the
script is called you will automatically have local variables
called $name, $address, and $phone with the values of
whatever was entered from the form.

use CGI;
my $q=new CGI;
foreach ($q->param()) {
 ${$_} = $q->param($_);

2.  Our company does most all of our dynamic web pages using
HTML templates (as opposed to embedding the HTML inside the
perl script).  The template files are set up with tokens
that are replaced with actual values from the script. 
Here's how we read in the template file, and replace all
tokens with actual values from the script:

$t = "new_fast_tag.htm";
undef $/;
open (T, "templates/$t") or die ("Can't open $t: $!");
$T = <T>;
close T;
$T =~ s/\[(.*?)\]/${$1}/g;
print $T;

******* PLEASE NOTE *******
Our area code has changed!
******* PLEASE NOTE *******

Mark A. Sharkey
World Class Web Sites
mark at
800 844 4434 (toll free)
480 461 9765 (local)
480 461 9312 (fax)

More information about the Phoenix-pm mailing list