perl-script vs cgi-script

--0016364d22e5a5a5c6048ccd0480
Content-Type: text/plain; charset=ISO-8859-1

Hi,

I'm relatively new to perl so bear with me please. I'm seeing a strange
behavior with perl

When I use the following config in apache

<VirtualHost *:80>
ServerName perly
DocumentRoot /var/www/perl/perly

<Directory /var/www/perl/perly>
AddHandler perl-script .pl
PerlOptions ParseHeaders
PerlHandler ModPerl::Registry
PerlSendHeader On
Options Indexes ExecCGI
AllowOverride All
Order allow,deny
Allow from All
</Directory>
</VirtualHost>

The following code
#!/usr/bin/perl -w
use strict;
use warnings;
use DBI;
use Cwd;
use CGI::Pretty qw(:standard);

my %config = (
host => 'localhost',
database => 'perly',
username => 'root',
password => ''
);

my $dbh = DBI->connect("dbi:mysql:".$config{'database'},
$config{'username'}, $config{'password'});

print header,
start_html(-title => 'Please Login',
-base => 'true',
-target => '_blank',
-meta => {'keywords' => 'login',
'description' => 'This is the login screen'},
-style => {'src'=>'/styles/style1.css'} );
require("/var/www/perl/perly/login.pl");
print end_html;
print "\n";

The login.pl file gets executed only once. Upon subsequent refreshes it
dissapears.
If I have AddHandler cgi-script .pl above, the script works fine.

Can someone please help me fix this issue?

Thanks,

Roland

--0016364d22e5a5a5c6048ccd0480
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hi,<br><br>I'm relatively new to perl so bear with me please. I'm s=
eeing a strange behavior with perl<br><br>When I use the following config i=
n apache<br><br><VirtualHost *:80><br>=A0 ServerName perly<br>=A0 Doc=
umentRoot /var/www/perl/perly<br>
<br>=A0 <Directory /var/www/perl/perly><br>=A0=A0=A0 AddHandler perl-=
script .pl<br>=A0=A0=A0 PerlOptions ParseHeaders<br>=A0=A0=A0 PerlHandler M=
odPerl::Registry<br>=A0=A0=A0 PerlSendHeader On <br>=A0=A0=A0 Options Index=
es ExecCGI<br>=A0=A0=A0 AllowOverride All<br>
=A0=A0=A0 Order allow,deny<br>=A0=A0=A0 Allow from All<br>=A0 </Director=
y><br></VirtualHost><br><br>The following code<br>#!/usr/bin/perl =
-w<br>use strict;<br>use warnings;<br>use DBI;<br>use Cwd;<br>use CGI::Pret=
ty qw(:standard);<br>
<br>my %config =3D (<br>=A0=A0=A0 host=A0=A0=A0=A0 =3D> 'localhost&#=
39;,<br>=A0=A0=A0 database =3D> 'perly',<br>=A0=A0=A0 username =
=3D> 'root',<br>=A0=A0=A0 password =3D> ''<br>);<br><=
br>my $dbh =3D DBI->connect("dbi:mysql:".$config{'database=
'}, $config{'username'}, $config{'password'});<br>
<br>print header,<br>start_html(-title=A0=A0 =3D>=A0 'Please Login&#=
39;,<br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 -base=A0=A0 =3D>=A0 'true&=
#39;,<br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 -target =3D>=A0 '_blank&#=
39;,<br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 -meta=A0=A0 =3D>=A0 {'keyw=
ords'=A0=A0=A0=A0 =3D>=A0 'login',<br>
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A0=A0=A0=A0 &#=
39;description'=A0 =3D>=A0 'This is the login screen'},<br>=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 -style=A0 =3D>=A0 {'src'=3D>=
;'/styles/style1.css'} );<br>require("/var/www/perl/perly/<a h=
ref=3D"http://login.pl">login.pl</a>");<br>
print end_html;<br>print "\n";<br><br>The <a href=3D"http://login=
..pl">login.pl</a> file gets executed only once. Upon subsequent refreshes i=
t dissapears.<br>If I have AddHandler cgi-script .pl above, the script work=
s fine.<br>
<br>Can someone please help me fix this issue?<br><br>Thanks,<br><br>Roland=
<br><br><br>

--0016364d22e5a5a5c6048ccd0480--
Roland Mai [ Mo, 02 August 2010 03:21 ] [ ID #2045405 ]

Re: perl-script vs cgi-script

>>>>> "Roland" == Roland Mai <roland.mai [at] gmail.com> writes:

Roland> The login.pl file gets executed only once. Upon subsequent refreshes it
Roland> dissapears.

What does that mean? Does it generate content? Are there any errors in
the error log? Can you log that it is being actually invoked?

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn [at] stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
merlyn [ Mo, 02 August 2010 03:49 ] [ ID #2045406 ]

Re: perl-script vs cgi-script

--0016e6d7e8ffb40b34048ccd780f
Content-Type: text/plain; charset=ISO-8859-1

Well, Anthony Esposito replied to me personally explaining that the files
get compiled once, I suppose to speed things up. So, the login.pl gets
rendered only once (when it's compiled), but not thereafter. The solution is
to turn the stuff in login.pl into a method and invoke it later.

On Sun, Aug 1, 2010 at 9:49 PM, Randal L. Schwartz <merlyn [at] stonehenge.com>wrote:

> >>>>> "Roland" == Roland Mai <roland.mai [at] gmail.com> writes:
>
> Roland> The login.pl file gets executed only once. Upon subsequent
> refreshes it
> Roland> dissapears.
>
> What does that mean? Does it generate content? Are there any errors in
> the error log? Can you log that it is being actually invoked?
>
> --
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
> <merlyn [at] stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
> Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
> See http://methodsandmessages.vox.com/ for Smalltalk and Seaside
> discussion
>

--0016e6d7e8ffb40b34048ccd780f
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Well, Anthony Esposito replied to me personally explaining that the files g=
et compiled once, I suppose to speed things up. So, the <a href=3D"http://l=
ogin.pl">login.pl</a> gets rendered only once (when it's compiled), but=
not thereafter. The solution is to turn the stuff in <a href=3D"http://log=
in.pl">login.pl</a> into a method and invoke it later.<br>
<br><div class=3D"gmail_quote">On Sun, Aug 1, 2010 at 9:49 PM, Randal L. Sc=
hwartz <span dir=3D"ltr"><<a href=3D"mailto:merlyn [at] stonehenge.com">merly=
n [at] stonehenge.com</a>></span> wrote:<br><blockquote class=3D"gmail_quote"=
style=3D"margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 2=
04); padding-left: 1ex;">
>>>>> "Roland" =3D=3D Roland Mai <<a href=3D"ma=
ilto:roland.mai [at] gmail.com">roland.mai [at] gmail.com</a>> writes:<br>
<br>
Roland> The <a href=3D"http://login.pl" target=3D"_blank">login.pl</a> f=
ile gets executed only once. Upon subsequent refreshes it<br>
Roland> dissapears.<br>
<br>
What does that mean? =A0Does it generate content? =A0Are there any errors i=
n<br>
the error log? =A0Can you log that it is being actually invoked?<br>
<font color=3D"#888888"><br>
--<br>
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095=
<br>
<<a href=3D"mailto:merlyn [at] stonehenge.com">merlyn [at] stonehenge.com</a>> =
<URL:<a href=3D"http://www.stonehenge.com/merlyn/" target=3D"_blank">htt=
p://www.stonehenge.com/merlyn/</a>><br>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.<br>
See <a href=3D"http://methodsandmessages.vox.com/" target=3D"_blank">http:/=
/methodsandmessages.vox.com/</a> for Smalltalk and Seaside discussion<br>
</font></blockquote></div><br><br>

--0016e6d7e8ffb40b34048ccd780f--
Roland Mai [ Mo, 02 August 2010 03:53 ] [ ID #2045407 ]
Webserver » gmane.comp.apache.mod-perl » perl-script vs cgi-script

Vorheriges Thema: Register now for Surge 2010
Nächstes Thema: File transfer with Apache2::Upload and XMLHttpRequest