http://www.perlmonks.org?node_id=18806

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question: (cgi programming)

Is there a difference .pl and .cgi extensions?

Originally posted as a Categorized Question.

  • Comment on Is there a difference .pl and .cgi extensions?

Replies are listed 'Best First'.
Re: Is there a difference .pl and .cgi extensions?
by cleen (Pilgrim) on Jun 19, 2000 at 20:55 UTC
    these are just extentions, which can be configured on the web server itself. You could do a .hiImaFreak and as long as its defined as executable in the httpd configuration it will run.
      This is correct for all but IIS-based servers. IIS uses the system file associations. I don't know what the Windows-based non-IIS servers do.

      --Chris
        Most of them, save Apache, use the system file extensions as well. Apache uses its own configurations, but then, Apache on NT is much the worse for it.

        However, that doesn't change the issue much. You can still define any extension as executable in IIS. Just create the File Type registry key either manually or through the View>Options>File Types menu in Windows Explorer.

        - Ozymandias

Re: Is there a difference .pl and .cgi extensions?
by merlyn (Sage) on Jun 19, 2000 at 21:06 UTC
    Not really. Both are unneeded extensions on Unix, that drive me and many other experts nuts. You don't call cat as cat.c! A user should not need to know the implementation language to invoke a program.

    Additionally, when used as part of a URL, they give away the implementation language to random users out on the net--a major security hole.

    So if your webserver or O/S needs an "extension" to determine that it's a CGI script or a Perl script, please don't use it for anything other than a toy. Real web servers don't need or use those.

Re: Is there a difference .pl and .cgi extensions?
by tenatious (Beadle) on Aug 18, 2000 at 06:40 UTC
    It's convention only. Kinda like when a M$Word document is named icky.doc. People like to use .pl for perl libraries, which may be required and reused. Naming a script cool.cgi makes it easy to identify cgi scripts, and allows security conscious system administrators to take proper precautions since they can be world executable.
RE: is there a difference with the extension .pl and .cgi?
by Anonymous Monk on Jun 19, 2000 at 20:52 UTC
    Well, the problem is that I'm running my web scripts on a NT server instead of a Unix server. All my .pl files work but when I try doing my upload script which is in .cgi it doesn't seem to work. It gives me a page not found error. Anyone with a solution?
RE: is there a difference with the extension .pl and .cgi?
by Anonymous Monk on Jun 19, 2000 at 20:53 UTC
    Well, the problem is that I'm running my web scripts on a NT server instead of a Unix server. All my .pl files work but when I try doing my upload script which is in .cgi it doesn't seem to work. It gives me a page not found error. Anyone with a solution?
RE: is there a difference with the extension .pl and .cgi?
by Anonymous Monk on Jun 19, 2000 at 22:21 UTC
    sorry that didn't work either. Did you check out my code, I just started using perl so not too good with it. Thanks for your help.
(jcwren) RE: is there a difference with the extension .pl and .cgi?
by jcwren (Prior) on Jun 19, 2000 at 20:55 UTC
    The problem is the file association type. .pl is associated with running perl, while .cgi is not. If you've installed ActiveState, it came with some instructions explaining how to associate the .pl with perl. You need to do the same thing, only substitute .cgi for .pl.

    I used to have instructions handy for doing that, but no more. It may by (or if not, should be) in the Q&A section of the monastery.

    Sorry I can't be more specific how to fix it...

    --Chris
RE: is there a difference with the extension .pl and .cgi?
by merlyn (Sage) on Jun 19, 2000 at 22:32 UTC
    In my webserver, CGI scripts are defined by a combination of things, but most commonly by the fact that they reside in a particular directory.

    -- Randal L. Schwartz, Perl hacker