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

i dont have perl on my computer, but i have it on my webserver. I created a module out of the code which was going to be used several times in my project, and i transfered it to the webserver.the file extension i saved the file as .pm .now my question is ... does the .pm extension tell the webserver that it is a perl file and needs to be compiled as perl? when i place the file with its path in the url bar of the browser, it asks me do u want to save the file or find a program online to run it? what program will you choose to open this file with... ketaki

Replies are listed 'Best First'.
Re: how to compile it
by jethro (Monsignor) on Jul 05, 2008 at 12:51 UTC
    A module is normally called from other perl programs, it is like a library file (dll file if you live in the windows world). So executing it is somewhat the wrong idea.

    Webservers will usually only recognize files with extension .pl as executables in their config, or a special directory for executable files (often called .../cgi_bin), or require you to add a .htaccess file (see documentation of the webserver for the details) to directories you want to make executable

    ++ to the Anonymous Monk who mentioned the cgi help guide, a nice summary of cgi problems

Re: how to compile it
by Anonymous Monk on Jul 05, 2008 at 11:46 UTC
Re: how to compile it
by pc88mxer (Vicar) on Jul 05, 2008 at 14:54 UTC
    does the .pm extension tell the webserver that it is a perl file and needs to be compiled as perl?
    No - there are many other factors involved. Usually what you would do is:

    1. Make the first line of your program reads #!perl. In some cases you might need to put the full path to perl on this line: #!/usr/local/bin/perl.

    2. Make sure it is executable (i.e. use chmod)

    3. Name your program myscript.cgi (.cgi is a common suffix for CGI programs).

    4. Ensure that your web server will treat files ending in .cgi as CGI programs.

    Sometimes scripts need to reside in a special directory in order to be treated as CGI scripts. Check your web server's configuration (or change it.)

Re: how to compile it
by Anonymous Monk on Jul 05, 2008 at 12:24 UTC
    webservers are like vehicles, they all have some kind of engine ... but a tractor is different from a rocket, and unless you know the make and model and consult the owners manual, you'll struggle to find the door, toilet ...