in reply to Creating a pseudo-module/package on a remote (CGI) server?

You could just build your Module.pm files along side your scripts and load them from there. You don't need to install them in the usual perl libdirs... In fact, unless I'm intending to distribute the modules for others normally don't put them in a different directory at all. Really, you can put them anywhere, as long as you -I the dir or add them to @INC before you use them — usually requres a BEGIN block..

Is there some file-filter machine that's preventing you from uploading anything with a .pm extension? You could even call them .pl files and require them by name.

-Paul

Replies are listed 'Best First'.
Re^2: Creating a pseudo-module/package on a remote (CGI) server?
by dirving (Friar) on Dec 21, 2006 at 09:41 UTC

    Just one extra tip in addition to jettero's advice: The easiest way to add another directory to your library path is to put use lib '/path/to/directory/with/modules'; at the top of your script. After you do that, you can use your own modules as if they were installed in the normal place -- you can even upload pure-perl modules from CPAN there and have them work fine.

    Note that you probably don't want to just put the modules alongside your script, though -- it's a good idea to put your modules in a directory that's not web-accessible so there is no risk of visitors to your site being able to view their source code.

Re^2: Creating a pseudo-module/package on a remote (CGI) server?
by PockMonk (Beadle) on Dec 21, 2006 at 10:15 UTC
    Aha! Thanks for your reply. My scripts are in "/cgi-bin" but I can access "/" (non web-accessible) so I could create a subdir there called modules and upload my newly created *.pm files just fine. I didn't realise that I could use modules in this way - everything I read stated I had to install them first, which I can't do as stated. I shall have a look at BEGIN, @INC and "-|" as suggested, thanks!

    But basically, you're saying I can simply upload them to a subdirectory as .pm, specify the modules folder local path as a lib, and then use "use" etc to access them exactly as if they were an installed module? Great!

      You may note that . disappears from @INC if you're running with taint checking, which you are forced to have when running as root ...

      Not that you'd ever dream of running your webserver or CGI scripts as root... but just so you know

      use lib 'lib'; seems a farily nice alternative (you can stick it at the top of your scripts, right where you've got use strict; use warnings;

      Throw those suckers into a skeleton script and you're away...

      @_=qw; ask f00li5h to appear and remain for a moment of pretend better than a lifetime;;s;;@_[map hex,split'',B204316D8C2A4516DE];;y/05/os/&print;