ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perlex
perlex
RE: PerlEx, namespace, and it used to work
by David Hempy other posts by this author
Sep 22 2005 10:30AM messages near this date
RE: PerlEx, namespace, and it used to work | Suggestions for debugging memory leak in persistent app?
SERVICES At 09:06 AM 9/22/2005, jonathan eisenhamer wrote:

> When main.plex is run from the command line, every is fine.  When called through the webser
ver running PerllEx, it fails with an 'undefined function "theSub"' error.

Generally, that kind of symptom (differences between command line and CGI execution) is usua
lly related to user rights or (less often) environment variables.  In your case, I'd suspect
 the latter. 

Log in as your webserver user (or use "runas") and see how your script fares from the comman
d line as that user.  If you have the flexibility, you can try briefly running your webserve
r as your user or as administrator.  Just don't forget to change it back, and don't be tempt
ed to just leave it that way as a solution.

 From the command line, run the command "set" and compare those variables to those available
 in your CGI environment.  You can use the script copied below to dump those variables.  If 
you have any special local environment variables, add them to the list.  This may illuminate
 some issue.

Also, this is a shot in the dark, but you might print the @INC variable in both environments
.  Also check what the current directory of each is.  Consider the FindBin module?  Is the s
ame installation of perl being invoked for each?

Good luck,
-dave




#!perl.exe

#Unlike perl.exe, under PerlEx the environment variable hash %ENV is magical. We have to ask
 the web server for each environment variable individually. On program load, keys(%ENV) will
 only return 3 keys. If you need to use an environment variable, you will have to explicitly
 ask for it. The following code will cause the %ENV to fill up with most of the available en
vironment variables:


my (@list)=qw( GATEWAY_INTERFACE HTTPS HTTP_ACCEPT HTTP_ACCEPT_ENCODING
                HTTP_ACCEPT_LANGUAGE HTTP_COOKIE HTTP_CONNECTION HTTP_HOST HTTP_REFERER
                HTTP_USER_AGENT PATH REMOTE_ADDR REMOTE_HOST REQUEST_METHOD REMOTE_USER
                SCRIPT_NAME SERVER_NAME SERVER_PORT SERVER_PROTOCOL SERVER_SOFTWARE
                SERVER_URL SYSTEMROOT CONTENT_LENGTH QUERY_STRING );

my $thing="";

foreach $item (@list) {
        $thing=$ENV{$item};
}

print "Content-type: text/html\n\n
<font size=+3> $ENV{GATEWAY_INTERFACE} <Br> $ENV{SCRIPT_NAME} </font>
<table border=1 cellpadding=2 cellspacing=0> \n";

foreach $var (sort keys %ENV) {
        unless ($ENV{REMOTE_ADDR} =~ /^(192.168.|168.111.)/ ) {
                ## Don't show outsiders these fields:
                next if ($var =~ /^USER/i);
                next if ($var =~ /^COMPUTERNAME/i);
                next if ($var =~ /^PATH/i);
        }
        print "<tr> <td>\$ENV{<b>$var</b>} </td><td>$ENV{$var}</td></tr>\n";
}

print "</table> \n";

use Cwd;
my $cd = cwd;

print "Also of note:<p> 
<ul> 
<li>     HTTP_COOKIE is [" . $ENV{HTTP_COOKIE}."] </li>
<li>     \$0 is $0 </li>
<li>     time is " . (time) . " </li>
<li>     time is " . (scalar localtime) ." </li>
<li>   cd is $cd </li>
<li>  to see HTTP_REFERER, <a href=\"$ENV{SCRIPT_NAME}\">click here</a> </li>
</ul> 
<p>      <pre>" . `perl -v` ."</pre> 
<p> ";

   
Attachments:
env.pl
unknown1
unknown2
unknown3
unknown4
unknown5

Thread:
Jonathan Eisenhamer
Henning Møller-Nielsen
Henning Møller-Nielsen
Jonathan Eisenhamer
David Hempy

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved