Ask a Question related to PERL Miscellaneous, Design and Development.
-
Mike Mimic #1
Mod_perl & do()
Hi!
I tryed to use do() function in mod_perl 1.27 but as I found out that
does not work. For example
test.pl:
#!/usr/bin/perl
my $test = 0;
do 'text.cf';
print "Content-type: text/html\n\n";
print $test;
test.cf:
$test = 1;
prints 0 and not 1. Files are in the same directory and there is '.' in
@INC.
scalar eval `cat test.cf` works but I really would not like to use this.
I use this for including configuration data.
Mike
Mike Mimic Guest
-
mod_perl and GD
Using: Apache/2.0.48 (Unix) mod_perl/1.99_13-dev Perl/v5.8.3 gd version 2.0.22 GD.pm version 2.12 on Redhat 9: 2.4.20-28.9smp -
mod_perl 1.99 Apache 2.0.48
Hello, I built a sever with apache and perl (cgi), and i used the mod_perl to boost my server, it actually works 4x time faster with mod_perl. ... -
mod_perl: my $var=1 if ...
I'm having trouble understanding something in mod_perl. The sub handler is: sub handler { ...stuff deleted... my $var=1 if... -
[PHP] PHP and mod_perl
Walter Torres wrote: Looks like Apache 2? Not too familiar with that (still using 1.3.x myself), but it seems to me that SetHandler may be... -
PHP and mod_perl
Anyone have any idea why I can't run PHP and mod_perl in the same web structure? I am getting this in my error log... 2508:... -
Jay Tilton #2
Re: Mod_perl & do()
Mike Mimic <ppagee@yahoo.com> wrote:
: I tryed to use do() function in mod_perl 1.27 but as I found out that
: does not work. For example
:
: test.pl:
: #!/usr/bin/perl
: my $test = 0;
Declaring that $test with my() gives it file scope...
: do 'text.cf';
: print "Content-type: text/html\n\n";
: print $test;
:
: test.cf:
: $test = 1;
....so that $test is a completely different variable.
Jay Tilton Guest
-
Mike Mimic #3
Re: Mod_perl & do()
Hi!
I think that it is not true.> Declaring that $test with my() gives it file scope...
>
> : do 'text.cf';
> : print "Content-type: text/html\n\n";
> : print $test;
> :
> : test.cf:
> : $test = 1;
>
> ...so that $test is a completely different variable.
do 'text.cf' should simply include code (like C++ include pragma) so
that the code of the program would be
#!/usr/bin/perl
my $test = 0;
$test = 1;
print "Content-type: text/html\n\n";
print $test;
I have changed the program slightly to show the problem (test.cf is not
loaded).
test.pl:
#!/usr/bin/perl
my $test = 0;
print "Content-type: text/html\n\n";
do 'text.cf';
print $test;
test.cf:
print "Loaded.\n";
$test = 1;
It prints only 0.
Mike
Mike Mimic Guest
-
Andreas Kahari #4
Re: Mod_perl & do()
In article <bTB8b.2563$2B6.601880@news.siol.net>, Mike Mimic wrote:
[cut]> Hi!
>>> Declaring that $test with my() gives it file scope...[cut]> I think that it is not true.
The manual for 'do' (perldoc -f do) says:
[...] code evaluated with "do FILENAME" cannot see lexicals
in the enclosing scope [...]
--
Andreas Kähäri
Andreas Kahari Guest
-
Jay Tilton #5
Re: Mod_perl & do()
Mike Mimic <ppagee@yahoo.com> wrote:
: do 'text.cf' should simply include code (like C++ include pragma) so
: that the code of the program would be
:
: #!/usr/bin/perl
: my $test = 0;
: $test = 1;
: print "Content-type: text/html\n\n";
: print $test;
Actually, it would be like
#!/usr/bin/perl
my $test = 0;
$main::test = 1; # package variable, not lexical
print "Content-type: text/html\n\n";
print $test;
: I have changed the program slightly to show the problem (test.cf is not
: loaded).
:
: test.pl:
: #!/usr/bin/perl
: my $test = 0;
: print "Content-type: text/html\n\n";
: do 'text.cf';
^^^^^^^
^
: print $test;
:
: test.cf:
^^^^^^^
^
: print "Loaded.\n";
: $test = 1;
:
: It prints only 0.
It would help if the filenames were the same.
Including checks on whether the do() succeeds is always a good idea.
Jay Tilton Guest
-
Mike Mimic #6
Re: Mod_perl & do()
Hi!
Jay Tilton wrote:Changing my $test to our $test does the trick.> Actually, it would be like
>
> #!/usr/bin/perl
> my $test = 0;
> $main::test = 1; # package variable, not lexical
> print "Content-type: text/html\n\n";
> print $test;
Ups. Thanks. It was only a test script but you are right.> It would help if the filenames were the same.
> Including checks on whether the do() succeeds is always a good idea.
Thanks, it works now.
Mike
Mike Mimic Guest



Reply With Quote

