Ask a Question related to Macromedia Exchange Dreamweaver Extensions, Design and Development.

  1. #1

    Default config file

    Hi,

    I have a project that I need to write and in the past I would hard code
    a lot of information in pages that I should have put into a config file.
    I am wanting to know if there a website that example how to write a
    config file and how to the php call them.

    Thanks

    Chuck
    Payne Guest

  2. Similar Questions and Discussions

    1. Error loading XML file c:\windows\microsoft.net\framework\v1.0.3705\Config\machine.config
      I had many ASP.NET web applications that I created before I had to rebuild my machine. After a fresh install of XP Pro, VS.NET 2003, etc, I now...
    2. config file: a) what Module ? b) conditionals in config (for multiple hosts)
      Hi, a) I am looking for a module to handle config files. There are a number of these modules, like AppCconig. Any consensus about The Right...
    3. [PHP] config file
      Payne said the following on 9/19/2003 11:23 AM>> take a look at parse_ini() function
    4. reference.vb...and the web.config file?
      What is the reference.vb file. How is it created? Can it or is there a reason for it to be modified? And the web. config file? For tracing, I...
    5. Web.Config File
      Hi Jason, No, you can't restrict certain IP addresses or IP masks via the web.config. You can write your own httpHandler and likely do this, but...
  3. #2

    Default Config file

    What is the best way to read a config file for a perl script. I have
    some very ugly code that can do it, but I would like to find something
    cleaner.

    Thanks,
    Rod.


    Rod Guest

  4. #3

    Default RE: Config file

    > What is the best way to read a config file for a perl script. I have
    > some very ugly code that can do it, but I would like to find
    > something
    > cleaner.
    That depends very very much on the format of the config file.
    You could use open() to read the file and parse it's contents
    into some kind of useable data structure (variables, array, hash,...)

    One of my favorite ways though is to put the goods I use in lots and
    lots of places into a module and import the goods I need:


    use lib '/home/me/myperlmodules';
    use MySuperProgramConfig; # has all the stuff I want in @EXPORT

    Sorry I couldn't be more specific, I have no idea what your config
    file is like or what kind of info you're trying to get into the program
    :)

    Dmuey
    >
    > Thanks,
    > Rod.
    Dan Muey Guest

  5. #4

    Default RE: Config file

    I've used Config::IniFiles before and it works very nice, especially nice if
    you do a tie into a hash for all your values.

    [url]http://search.cpan.org/~wadg/Config-IniFiles-2.38/IniFiles.pm[/url]

    -Tom Kinzer




    -----Original Message-----
    From: Rod [mailto:scriptmonkey@iowatelecom.net]
    Sent: Tuesday, December 02, 2003 7:55 AM
    To: beginners
    Subject: Config file


    What is the best way to read a config file for a perl script. I have
    some very ugly code that can do it, but I would like to find something
    cleaner.

    Thanks,
    Rod.



    --
    To unsubscribe, e-mail: [email]beginners-unsubscribe@perl.org[/email]
    For additional commands, e-mail: [email]beginners-help@perl.org[/email]

    Tom Kinzer Guest

  6. #5

    Default RE: Config file

    > What is the best way to read a config file for a perl script. I have
    > some very ugly code that can do it, but I would like to find
    > something
    > cleaner.
    I've used Config::General for several production projects and it works
    quite well.

    Luke
    Luke Bakken Guest

  7. #6

    Default Re: Config file


    On Dec 2, 2003, at 7:55 AM, Rod wrote:
    > What is the best way to read a config file for a perl script.
    > I have some very ugly code that can do it, but I would like
    > to find something cleaner.
    I like the Config::General module someone has recommended,
    amongst the trade offs that one will have to resolve is how
    much Stuff do you need, and how to access that stuff, and
    how much 'generic parsing' as opposed to tailered parsing.

    remember that 'art is in the eye of the beholder'.

    My favorite way is in an OO'ish form where I start with
    something on the order of

    my $web_config = new Dtk::...::ToolConf;

    Then actually read them with

    #------------------------
    #
    sub set_values
    {
    my ($me) = @_;

    my $error = $me->webadmin_conf_file_name() unless $me->{file};
    return $error if (ref($error) eq 'HASH');

    open(FD, $me->{file}) or return({runtime_error =>
    "unable to open config file $me->{file} : $!\n"});

    while(<FD>)
    {
    chomp;
    s/#.*//; # strip comments
    next if /^\s*$/;
    if (/=/ ) {
    s/\s+=/=/; # clean spaces before =
    s/=\s+/=/; # clean spaces after =
    s/\s+$//; # clean trailing spaces
    s/^\s+//; # clean leading spaces
    my ($k, $v) = split(/=/);
    $me->{$k} = $v;
    }
    }
    close(FD);
    $me->{values_set} = 1;

    0;
    } # end of set_values

    And of course have a list of named accessors:

    #------------------------
    # The Accessors
    #------------------------

    sub config_sufix { $_[0]->{config_sufix} }
    sub config_dir { $_[0]->{config_dir} }
    sub bin_dir { $_[0]->{bin_dir} }
    sub webmin_root { $_[0]->{web_admin_root} }
    sub webmin_port { $_[0]->{web_admin_port} }
    sub db_url { $_[0]->{db_url} }

    and some other junk that has to do with sanity checking,
    and displaying them so that the config file can be
    edited and updated, and yada-yada-yada.

    { yes, could have used AutoLoader - tried that,
    it didn't take me where I wanted to go.... }

    A part of the question you really want to ask
    is how complex a config file do you want to begin
    with, and can you live with the issues that come
    from using a hash where the 'key/value' pairs are
    accessed directly by the calling code.

    Do you need to have complex configuration stuff,
    if so why not lookt at the LibXml approach...

    ciao
    drieux

    ---

    Drieux Guest

  8. #7

    Default Re: Config file


    >
    > On Dec 2, 2003, at 7:55 AM, Rod wrote:
    >
    > Do you need to have complex configuration stuff,
    > if so why not lookt at the LibXml approach...
    >
    Particularly I suggest XML::Simple it allows you to both create your
    config file and read in your config file using standard Perl data
    constructs and is reasonably quick for smaller purposes. I have also
    had luck with AppConfig since it hasn't been mentioned yet, at least I
    don't think. I have found XML the best bet for arbitrarily deep nested
    config files though...

    Whatever you decide, use a module!

    [url]http://danconia.org[/url]

    Wiggins D Anconia Guest

  9. #8

    Default Re: Config file

    Rod wrote:
    > What is the best way to read a config file for a perl script. I have
    > some very ugly code that can do it, but I would like to find something
    > cleaner.
    >
    > Thanks,
    > Rod.
    It depends on how the config file is set up. Asuming that your config
    file is a simple name= value per line file, it is very simple:

    my $options = {};

    open IN, $option_file_name or die "Could not open ini file: $!";
    while (defined my $line = IN) {
    next unless $line;
    my ($key, $value) = split /\s*=\s*/, $line;
    $options->{$key} - $value;
    }
    close IN;

    Joseph

    R. Joseph Newton Guest

  10. #9

    Default config file

    Hi yea,
    I am using a PC XP SP2 only me as a user on the machine,
    In my Documents and Settings Dir I have both a Administrator and an All
    User Dir.

    I find that in all I have 2 config folders.

    C:\Documents and Settings\Administrator\Application
    Data\Macromedia\Dreamweaver 8\Configuration <<<< that config fle
    is only 5 odd meg

    and

    C:\Documents and Settings\All Users\Application Data\Macromedia\Dreamweaver
    8\Configuration <<<< this config file is 40 odd meg

    when I back up my config file I usually back up the config in my All users
    dir, but I was wondering should i be backing up both.

    should I be having 2 config files.

    regards

    Kenny


    Twocans Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139