[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Re: newbie question



>Hello all;
>
>I am fairly new to Perl, with CGI experience.  I just downloaded MacPerl5.
>Is there a way to test Perl CGI scripts on Mac OS 8 with MacPerl?  How?
>
>Thanks
>Kathy

Hi Katy,
If you want to ask a question to the list, send the message to 
'macperl@macperl.org'.

You now sent the message to me personally.

It's fairly easy to test Perl CGI script on the Mac, provided they 
don't do specific 'unix' things like threading or calling command 
line programs.

Start your Web Sharing control panel

In Macperl, save the script as a 'CGI script' in the Web Pages 
folder. Use the extension '.acgi', as in mycgi.acgi. This way you 
won't have to set any special settings in the Web Server.

Call the cgi as you would on a unix server, except use either 
'localhost' or your IP number in the http address.

It's a long time ago, but I think this is it.

Below you'll find a cgi that was specifically written for the Mac Web 
Sharing control panel.

Bye,


Axel


------------------------------

#!perl
#
# CGI script to handle form requests
#
# <FORM  ACTION="../thankyou.acgi" METHOD="get">
#
# Written by A.M. Roest
# © Axel Development & Support
#
# Jouw voorstel voor de bestandsnamen is akkoord. De naam wordt dus
# sb<filiaalcode><yyyymmdd>.asc

# 
====================================================================== 
========
# The item below needs to be changed for every store
# use a three character store abbreviation
# 
====================================================================== 
========
$store = 'bae';
$datapath="the Luggage:Documenten:Projects:Inizio:dat:";

# ========================================================================
exit unless ($ENV{'REQUEST_METHOD'} eq "GET");

$| = 1;
# ========================================================================
# generate filename
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time);
#$rnd=(rand 900) + 100;
$year +=1900;
$mon+=1;
$filename = sprintf "sb$store%04u%02u%02u.asc",$year,$mon,$mday;

if ($query = $ENV{"QUERY_STRING"}) {
	# Redirect to the thankyou page
	print "HTTP/1.0 302 Found\n";
	#    print "Window-target: $in{'target'}\n" if ($in{'target'});
	print "Location: thankyou.html\n\n";

	# 
====================================================================== 
==
	# Now do your thing
	@data = split '\&', $query;

	foreach (@data) {
		($tag,$datum) = split '=';
		$dat2{$tag} = $datum;
	}

	# test availability of data file
	if ( -f "${datapath}$filename") {
		open(fout, ">>${datapath}$filename");
	} else {
		open(fout, ">${datapath}$filename");
	}
	if (fout) {
		print fout "naam=$dat2{naam}\n\r";
		print fout "adres=$dat2{adres}\n\r";
		print fout "pc=$dat2{pc}\n\r";
		print fout "plaats=$dat2{plaats}\n\r";
		print fout "sexe=$dat2{sexe}\n\r";
		print fout "geboren=$dat2{dag}$dat2{maand}$dat2{jaar}\n\r";
		print fout "email=$dat2{email}\n\r";
		close fout;
	}
}
# end if $query

_____________________________
Axel M. Roest                | AXEL Development & Support
info@axel.nu                 | Macintosh developer & UNIX sysadmin
http://www.axel.nu           | XOIP: 020-8749988

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org