Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I'm using a shared Freebsd server and it has an older version (3x) of CGI::Session installed. I'm using the newer 4.38 on my computer running XP and my scripts work. I needed to make quite a bit of changes to get them to work on the older CGI::Session version - in particular, this version doesn't support "load" and is quite a pain.

Can I simply copy the entire folder that contains CGI::Session (and its related files) from my computer to a folder on the shared server? Or must I install it from the server itself?

And after it's installed, how do I access the newer version? At this point, I know I've to add:

# Assumeing the folder containing CGI::Session is installed in '/usr/h +ome/mysite/modules/site/CGI/' use lib '/usr/home/mysite/modules'; use CGI::Session;

Does "use CGI::Session" call the older version installed by the hosting company or does it call the newer one I've installed?

Please enlighten me.

Thanks in advance :)

Replies are listed 'Best First'.
Re: How to use a new version of a module?
by friedo (Prior) on Dec 25, 2008 at 09:46 UTC
    use lib will prepend the directory you specify onto the beginning of @INC, so the Perl interpreter will look there first. I don't think CGI::Session has any compiled portions (but don't take my word for it) so copying the module to your local directory on the server should work fine.
Re: How to use a new version of a module?
by wfsp (Abbot) on Dec 25, 2008 at 11:08 UTC
    I've had similar problems with CGI::Session. Newer versions use Scalar::Util::refaddr. Older version of S::U won't have refaddr. S::Util is not pure Perl you can't just copy it to a local lib. Either ask the hoster to upgrade C::S (which will in turn upgrade S::U) or use the same version of C::S on your local m/c that the hoster has.

    Good luck!

Re: How to use a new version of a module?
by Anonymous Monk on Dec 25, 2008 at 11:37 UTC

    Hi friedo,

    Thanks to your enlightenment! I tried it again and finally got it to work. The first time, I missed out one folder name. I had "/usr/home/mysite/site/Session/". It should have been ""/usr/home/mysite/site/CGI/Session/". I discovered it after I went back to try again with your assurance. I recopied the entire folder containing CGI::Session (and its related files) to the server.

    I needed these lines in my scripts:

    use lib '/usr/home/mysite/modules'; use site::CGI::Session;

    I had to append "site::" to "CGI::Session". So now everything is working as expected, well, almost.

    In a few places I added the line below:
    $session->flush();

    Otherwise, the session data doesn't get stored the way it does on my local computer.

    To wfsp:

    Yes, it is quite confusing. I spent a long time getting it to work. Most tutorials or forum help I read about give the syntax CGI::Session->load('driver:File', undef, {Directory=>"/sessions"}). But "load" wouldn't work with anything below CGI::Session 4x (which I read about somewhere but I can't find the source).