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

I have been tasked with developing an INI editor for use on a *nix system. It will need to be able to add or update keys to an existing file. Has anyone done this? Is there a .pm out there to handle this kind of thing?

Your Humble Servant,
-Chuck

Replies are listed 'Best First'.
Re: *nix Based INI editor
by mikfire (Deacon) on Apr 12, 2000 at 20:55 UTC
    A quick search of CPAN turns up IniConf-0.97. It is still pre-release, but the documentation looks pretty decent.

    Mik Mik Firestone ( perlus bigotus maximus )

Re: *nix Based INI editor
by jbert (Priest) on Apr 13, 2000 at 14:30 UTC
    What is your requirement?

    If
    a) you only need to change this file programatically
    and
    b) you only need to store scalars per value
    then consider a tied hash. (See 'perltie' for info & examples).

    Example: (untested, yadda yadda)

    use Fcntl; use SDBM_File; tie (%ini, 'SDBM_File', $ini_db_file, O_RDWR, 0640) or die( "Tie-dye :-) : $!" ); my $last_time = $ini{last_run_time}; if( $last_time ) { print "Last run was [$ini{last_run_time}] seconds after the epoch\n" +; } else { print "Never been run before...\n"; } $ini{last_run_time} = time(); untie %ini;
    Basically it gives you a persistent hash over different runs of your script.

    If you want to store data other than scalars you'll need to 'flatten' them somehow. Often this can be a join & split exercise, but they are other ways (and a module called Data::Dumper) to do this.

Re: *nix Based INI editor
by Lord Rau (Novice) on Apr 12, 2000 at 19:13 UTC
    I have one but it's completely undocumented... Well there are some comments in the code.
      Chuck send me an email at spamthis@nc.rr.com and I'll be happy to send it to you.