in reply to $Bin undef with FindBin in web environment

Can someone suggest another solution to this problem?

  1. Use a cgi-bin/YourLib/Widget.pm stucture ie use lib './YourLib' is all you need in your CGIs
    • this breaks if you call the script without cgi-bin being the cwd as pointed out by Corion
  2. Install your libs in the usual Perl way as this removes the lib issue as @INC covers it.
  3. Using configuration constants, set up on install gives yet another option.

cheers

tachyon

  • Comment on Re: $Bin undef with FindBin in web environment

Replies are listed 'Best First'.
Re^2: $Bin undef with FindBin in web environment
by Anonymous Monk on Sep 01, 2004 at 12:15 UTC
    Thank you for your suggestions.

    Regarding 1, isn't it generally a bad idea to place lib directories within a web root directory? In addition to mixing up different parts of the project, it makes it easier to mistakenly serve modules.

    Regarding 2, it is my preference to place all files associated with a project within a single 'project' directory. This makes it easier to find all files associated with the project, or to check out the project in one step.

    Three is a realistic option for a packaged product, but I'm not sure it is appropriate for a work in progress which will in the end only be installed on two servers. It seems like quite a lot of overhead (in time) to make a formal install process.

      The assumption with suggestion 1 is that your cgi-bin directory is outside the document root, as in the typical $somepath/htdocs/ + $somepath/cgi-bin/ scenario. If your cgi-bin is inside the document root as in $somepath/htdocs/cgi-bin/, then you would indeed be at risk of serving modules as plaintext — but you risk the same for your scripts, as well.

      Makeshifts last the longest.

        cgi-bin is outside the document root directory, in a script directory. I misunderstood your suggestion, which I thought was to place it all within the document root.

        In this case my objection is that the lib files are not strictly tied to the cgi scripts; they are also used by programs in bin/ for instance. Therefore it would seem like poor structure to me to put them within the cgi-bin directory.

        Furthermore, it would place the additional burden of knowing their place in nesting upon the scripts ('is it lib, ../lib, ../../lib, or ../../../lib?'). I tend to move programs around during development as new groupings become clear, despite the fact that cvs tries to disuade me from this practice.

        Anyhow, thank you for your help. I have decided to go with calculating the lib directory as described in my other replies, but I appreciate your suggestions.