in reply to Config::Tiny Module

Maybe you (=the webserver user who runs the CGI script) don't have permission to write to the file?

$Config->{section}->{ipaddress} = $newvalue; $Config->write( 'file.conf' );

works fine for me, as long as the file is writable.

Replies are listed 'Best First'.
Re^2: Config::Tiny Module
by packetstormer (Monk) on Mar 29, 2011 at 20:54 UTC
    Really!? It writes just not what it should.
    $Config->{section}->{ipaddress} = $newvalue; $Config->write( 'file.conf' );
    The above just doesn't write. Put the $newvalue is single quotes and it write "$newvalue" !
      Really!?

      Yes.  I tried with

      my $newvalue = '127.0.0.1'; ...

      and 127.0.0.1 is exactly what ended up in the file.

      As for single quotes: they don't interpolate, that's why you get "$newvalue" literally.

        There are 2 pages involved. The first is a form that passes the value $newvalue to the CGI script. The CGI script receives that value fine and I can dump it to screen fine.

        If I try and write that value to the config file one of two things happens. Firstly, if I single quote the value '$newvalue' it will write the literal string $newvalue to the config file. So this rules out any permissions issues with writing to the file.

        Any other format ("$newvalue" or \$newvalue) will not write to the file at all. It simply ignores it.

        If I set the variable value myself in the CGI script (that is, not pass it from a form) and then try and write that value to the file it works.
        Sorry - I should have been much clearer.

        Setting the variable in the same file works fine. Posting it from another form doesn't.