in reply to Where to store config info?

I apologize in advance if I have missed some nuance of your situation, but it seems to me that you should have one config file with all three IP addresses, in default search order. The application could read them in and try each in sequence until it found one that worked. To manually override the search order, you could set a command line parameter for what IP to try first, for example. It seems to me this would eliminate the need for write access to the file.

--cc

Replies are listed 'Best First'.
Re^2: Where to store config info?
by Anonymous Monk on Oct 16, 2009 at 12:28 UTC
    The problem is where to put this one config file. The module that needs it is designed to run in lots of different environments, under Windows, Linux and Solaris, Web- and Script-based, so I cannot just hardcode e.g. /etc/myapp or whatever. What I need is some perl mechanism to find a config file without hardcoding the exact location.
      Why not just stick your configuration in /opt/appname/etc/config.file ? You can create an /opt/appname/etc on Windows, right?

      Options:

      • Search in the current directory for appname.conf / appname.ini or the like
      • Search in the directory containing the main script (i.e. dirname($0).'/appname.conf')
      • Place all your executable scripts in somewhere/bin, place the configuration files in somewhere/etc, and place your own modules in somewhere/lib. Use C<$FindBin::Bin> to locate your executable, take its dirname(), replace '/bin' with '/etc/appname.ini'.
      • Require that an environment variable is set up to point to your configuration file. Refuse to work unless it is set.
      • Pass the name of the configuration file as command line argument (does not work in web environment).
      • Search in the "usual" places: /etc/appname.conf or /etc/appname/setup.conf, and $HOME/.appname or $HOME/.appname/setup.conf on Unix-like systems, H:\Documents and Settings\Joe User\Application Data\AppName on Windows. Don't hardcode the path names on Windows, they keep changing from translation to translation and from version to version. Use Win32::GetFolderPath(CSIDL_xxx).

      Note that forward slashes work both on Unix-like systems AND on Windows. Only some stupid Windows command line utilities can't handle file names with forward slashes. Even ancient DOS versions DO support forward slashes in path names at the API level (i.e. INT 0x21), only the applications refused to pass forward slashes to the API.

      Alexander

      --
      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)