[sorry for following up my own post] On 12/1/06, Bill Jones <[EMAIL PROTECTED]> wrote:
Yes, the 'use CGI' stuff will work even on the command-line (ie, when not used in a CGI/HTTP gateway) environment.
A specific example - #! /usr/bin/perl -wT use CGI; use strict; use warnings; use diagnostics; my $q = CGI->new(); my %params = $q->Vars; # See http://hoohoo.ncsa.uiuc.edu/cgi/env.html if ($ENV{GATEWAY_INTERFACE} and $ENV{GATEWAY_INTERFACE} =~ /CGI/i) { print "Content-Type: text/html\r\n\r\n ... I'm running as a CGI ...<br/>"; foreach my $key (keys %ENV) { print "$key --> $ENV{$key}<br/>"; } } print "<PRE>\n" if $ENV{GATEWAY_INTERFACE}; foreach my $f (keys (%params)) { print "$f: $params{$f}\n"; } print "</PRE>\n" if $ENV{GATEWAY_INTERFACE}; __END__ And on the command-line call it like: perl -wT somefile.pl some variables and params Via the www call it like: http://somehost/some/path/someprog.cgi?varx=vary&this=that You get example output like this (via WWW) ... I'm running as a CGI ... SCRIPT_NAME --> /~bjones/index.cgi SERVER_NAME --> fc6.insecurity.org SERVER_ADMIN --> [EMAIL PROTECTED] HTTP_ACCEPT_ENCODING --> gzip,deflate HTTP_CONNECTION --> keep-alive REQUEST_METHOD --> GET HTTP_ACCEPT --> text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 SCRIPT_FILENAME --> /home/bjones/public_html/index.cgi SERVER_SOFTWARE --> Apache/2.2.3 (Debian) mod_python/3.2.10 Python/2.4.4c0 PHP/4.4.4-8 mod_perl/2.0.2 Perl/v5.8.8 HTTP_ACCEPT_CHARSET --> ISO-8859-1,utf-8;q=0.7,*;q=0.7 QUERY_STRING --> varx=vary&this=that REMOTE_PORT --> 40145 HTTP_USER_AGENT --> Mozilla/5.0 (X11; U; Linux ppc; en-US; rv:1.8.0.7) Gecko/20060830 Firefox/1.5.0.7 (Debian-1.5.dfsg+1.5.0.7-2) SERVER_PORT --> 80 SERVER_SIGNATURE --> Apache/2.2.3 (Debian) mod_python/3.2.10 Python/2.4.4c0 PHP/4.4.4-8 mod_perl/2.0.2 Perl/v5.8.8 Server at fc6.insecurity.org Port 80 HTTP_ACCEPT_LANGUAGE --> en-us,en;q=0.5 REMOTE_ADDR --> 127.0.1.1 HTTP_KEEP_ALIVE --> 300 SERVER_PROTOCOL --> HTTP/1.1 PATH --> /usr/local/bin:/usr/bin:/bin REQUEST_URI --> /~bjones/index.cgi?varx=vary&this=that GATEWAY_INTERFACE --> CGI/1.1 SERVER_ADDR --> 127.0.1.1 DOCUMENT_ROOT --> /var/www/ HTTP_HOST --> fc6.insecurity.org varx: vary this: that -- WC (Bill) Jones -- http://youve-reached-the.endoftheinternet.org/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>