Gossamer Forum
Home : General : Perl Programming :

perl version and mod_perl

Quote Reply
perl version and mod_perl
Hi,

On my server I have two perl versions (its a raq so I couldn't just do a straight upgrade to the new version). I have mod_perl built on a backend server and sometimes it loads the correct version but sometimes it uses the old version. I find out because I start getting errors that modules aren't installed and if I look in the admin environment in Links it does show the old version. I've found that I can fix this when it happens by stopping both servers, restarting mod_perl and then restarting apache - at least that has worked so far - and just restarting mod_perl doesn't fix it. But I don't understand how it is getting the old version.

Any ideas what is going on or how I can stop it happening?

Thanks, Laura.
Quote Reply
Re: [afinlr] perl version and mod_perl In reply to
When you say it loads the wrong version, what do you mean?...mod_perl loads the modules you ask it to load.
Quote Reply
Re: [Paul] perl version and mod_perl In reply to
Its using the wrong version of perl. I thought that it should use the perl binary that I get from typing 'which perl' but sometimes it is using the old version. I don't understand how it is finding the old version. Is there somewhere I can tell it where perl is?
Quote Reply
Re: [afinlr] perl version and mod_perl In reply to
Do you mean Links SQL is showing the wrong version in the control panel?

If so, I believe the code uses $] to generate the version, which is interpretted by the currently active version of perl (ie the version running the admin script).

So it's likely /usr/bin/perl is still the old version for some reason. You should have /usr/bin/perl5.6.1 which you can use to make sure the proper version loads.

Last edited by:

Paul: May 22, 2003, 5:21 PM
Quote Reply
Re: [Paul] perl version and mod_perl In reply to
Yes its showing the wrong version in the control panel and I get error messages that the modules I need aren't in @inc because it is using the old libraries.

Yes I think this is because the version running the admin script is the old version.

But /usr/bin/perl is not the old version and sometimes the admin panel shows the correct version so I don't think it is as simple as that.

How do I tell it to use /usr/bin/perl5.6.1? Where should this instruction be? This is what has stumped me.
Quote Reply
Re: [afinlr] perl version and mod_perl In reply to
You'd just change the perl path in your cgi scripts and then restart mod_perl
Quote Reply
Re: [Paul] perl version and mod_perl In reply to
In which cgi scripts? I thought that mod_perl didn't take any notice of what you put at the top of your cgi files - I thought it just runs cgi files using the default perl version. Have I completely misunderstood?
Quote Reply
Re: [afinlr] perl version and mod_perl In reply to
mod_perl compiles your perl code and stores it in memory - you still need a shebang line in your links sql cgi scripts otherwise you'll get an internal server error.
Quote Reply
Re: [Paul] perl version and mod_perl In reply to
Well, here's my test:

I wrote 3 versions of a script:

shebang
print "Content-type: text/html\n\n";
print $];

and for the shebang line the first one is blank, the second one is #!/usr/bin/perl and the third is #!/usr/bin/perl5.005

If I load the first file in apache I get an error. The second one show 5.006 and the third one shows 5.005.

Now if I run the same three scripts under mod_perl I get 5.006 (even the one without a shebang line).
Quote Reply
Re: [afinlr] perl version and mod_perl In reply to
Hmm I think I must be going brain dead.

I think mod_perl will use the version of perl that mod_perl was compiled against and so in order to get it to use another version, you'd need to re-configure and build mod_perl
Quote Reply
Re: [Paul] perl version and mod_perl In reply to
I've done that. I have recompiled it with the correct version.

Sometimes it uses the correct version and sometimes it uses the old version - I don't understand how? I'm sure this isn't a straightforward problem and is some strange problem specific to my server but I don't understand how it is happening.
Quote Reply
Re: [afinlr] perl version and mod_perl In reply to
I'm not sure. The only thing I can think of is that it didn't update properly when you recompiled.
Quote Reply
Re: [Paul] perl version and mod_perl In reply to
Thanks. I'll try recompiling it again and see what happens.