You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Roland Mai <ro...@gmail.com> on 2010/08/02 03:21:20 UTC

perl-script vs cgi-script

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

Re: perl-script vs cgi-script

Posted by Roland Mai <ro...@gmail.com>.
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 <me...@stonehenge.com>wrote:

> >>>>> "Roland" == Roland Mai <ro...@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
> <me...@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
>

Re: perl-script vs cgi-script

Posted by "Randal L. Schwartz" <me...@stonehenge.com>.
>>>>> "Roland" == Roland Mai <ro...@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
<me...@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