Bob Anderson,bazooka@well.com,Internet writes: > >Hello, I'm new to the list and a rank newbie to MacPerl > >(and not much better with Perl) so please excuse my ignorance. No problem. It's how all of us started out. Believe me. > > >I'm trying to translate some perl scripts used on a Unix server. > > >I would like to use something like this perl script, > >except it should be for the MacOS: > >---start script--- > >#!/usr/local/perl > >print "Content-type: terxt/html\n\n"; > >foreach $k (keys %ENV) { > print "$k = $ENV{$k}<br>; >} > >---end script--- > > >Now I do understand that the MacOS does not use enviornmental variables, > >what I would like to get are the CGI arguements returned to me via a > >MacPerl CGI. The MacOS doesn't use environment variables, it's true, but the MacPerl CGI glue can fake it. First get the MacPerl tools from the same place you got MacPerl (try CPAN or Matthias's site). The tools addition to MacPerl allows you to save your scripts as "CGI Script". > The second tricky bit about MacPerl is that the %ENV variables don't exists until you call them by name. I know, I know: it makes no sense (and I think Matthias is fixing it), but it's just how it is. The loop you wrote above won't work. But is you call each variable you want like $ENV{HTTP_REFERER} it will show up from that point on. Try this: #!perl -w print "Content-type: text/html\r\n\r\n"; @List = ('HTTP_REFERER','USER_AGENT','CONTENT_TYPE'); # add as you like foreach $Var (@List) { print "$Var = $ENV{$Var}<br>\n"; } exit(0); If you want to get the arguments, the best way is to use either CGI.pm or CGI-Lite.pm. I've attached the CGI-Lite.pm for you. Here's an example of how to use it: --- use cgi_lite; $InCGI = new CGI_Lite(); $HashRef = $InCGI->parse_form_data(); $Var = $$HashRef{form_field_name}; --- Or (when you POST) you could read the list of arguments from the STDIN: --- read(STDIN, $Var, $ENV{"CONTENT_LENGTH"}); # read POST value --- I hope this helps! -josh PS. To get MacPerl stuff: <ftp://sunsite.cnlab-switch.ch/software/platform/macos/perl/> > > ----------------------------------------------------------------- Open Learning Agency 4355 Mathissi Place, Burnaby, B.C. Canada, V5G 4S8 (604) 431-3000 #!/usr/local/bin/perl5 -w################################################################################### CGI_Lite v1.0 #### Supports the following encoding methods:## - application/x-www-urlencoded## - multipart/form-data#### Copyright (c) 1995 by Shishir Gundavaram## All Rights Reserved#### This program is free software. You can redistribute it and/or## modify it, but I require that this credit appear in the code.##################################################################################### Here is what a multipart/form-data header might look like:################################################################################### --AaB03x## content-disposition: form-data; name="full_name"#### Foo Bar#### --AaB03x## content-disposition: form-data; name="picture"; filename="/foo/bar.gif"## Content-Transfer-Encoding: binary#### ... GIF Data ...#### --AaB03x#### content-disposition: form-data; name="readme"; filename="/foo/bar.txt"##! ! ! ## ... Text Data ...#### --AaB03x--################################################################################### Here are the list of functions you can use:#### - parse_form_data ()#### This will handle all types of requests: GET, HEAD and## POST (for both encoding methods). For multipart/form-data,## uploaded files are stored in the specified directory## with the same name, as containe ***** Want to unsubscribe from this list? ***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch