According to the guide, the snazzy way to export a huge "Constants" array is

package Constants;
use vars qw(%c);
%c = (
);

package myPack;
use vars qw(%c);
*c=\%Constants::c;

But I don't remember the URL in the Guide that would say this.


-----Original Message-----
From: valerian [mailto:[EMAIL PROTECTED]]
Sent: Saturday, August 31, 2002 8:39 PM
To: [EMAIL PROTECTED]
Subject: Apache::PerlRun weird behavior?


Hi I'm new at mod_perl, and I decided to start running my scripts with
Apache::PerlRun so I don't have to rewrite them right away (they're too
'dirty' to run under Apache::Registry).  Anyway, I figured it was going
to be easy since PerlRun provides an environment similar to CGI, but
something strange is happening.  There's a section in the User Guide that
talks about possible problems one can encounter with referenced
variables, so I figured I'd write a very simple test script to see if
that was the case with my code.

So the weird thing is that it runs fine the first time, but when I
reload the page, it doesn't show the variable I imported from
My::Config, and this is what the output looks like this:
        html_dir =
        count = 1
And this message shows up in the error.log:
[Sat Aug 31 19:59:15 2002] test.pl: Use of uninitialized value at
/home/val/www/cgi-bin/test.pl line 12.

This is such a simple script, but I can't figure out what I'm doing
wrong.  What's even more weird is that if I change my httpd.conf to use
Apache::Registry instead of Apache::PerlRun, the script works fine!
(well the value of $count keeps incrementing, but I expected that).

Could someone please tell me what I'm doing wrong?  My settings/code are
shown below:


----- httpd.conf -----
PerlWarn On
PerlTaintCheck On
PerlModule CGI
Alias /cgi-perl/ /home/val/www/cgi-bin/
<Location /cgi-perl>
        SetHandler perl-script
        PerlHandler Apache::PerlRun
        Options +ExecCGI
        allow from all
</Location>


----- test.pl -----
#!/usr/bin/perl -w
use strict;
use CGI;
use My::Config;
use vars qw($count);

my $q = new CGI;

$count++;

print $q->header(-type=>'text/html');
print "html_dir = $CF{'html_dir'}<br>";
print "count = $count<br>";


----- My/Config.pm -----
package My::Config;
use strict;
use Exporter;
use vars qw(@ISA @EXPORT %CF);
@ISA = ('Exporter');
@EXPORT = qw(%CF);

$CF{'html_dir'} = '/home/val/www/htdocs';

1;

------------------------------------------------------------------------------
This message is intended only for the personal and confidential use of the designated 
recipient(s) named above.  If you are not the intended recipient of this message you 
are hereby notified that any review, dissemination, distribution or copying of this 
message is strictly prohibited.  This communication is for information purposes only 
and should not be regarded as an offer to sell or as a solicitation of an offer to buy 
any financial product, an official confirmation of any transaction, or as an official 
statement of Lehman Brothers.  Email transmission cannot be guaranteed to be secure or 
error-free.  Therefore, we do not represent that this information is complete or 
accurate and it should not be relied upon as such.  All information is subject to 
change without notice.


Reply via email to