Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Config file help

by Adrade (Pilgrim)
on Jun 23, 2005 at 23:10 UTC ( #469557=note: print w/replies, xml ) Need Help??

in reply to Config file help

For config stuff like that, I think DB_File comes in handy... you could easily, from within both programs, do this:
#!/usr/bin/perl use DB_File; use CGI 'param'; print "Content-type: text/plain\n\n"; my $filename = '/path/to/database'; tie %hash, "DB_File", $filename, O_RDWR|O_CREAT; print 'thisvar: ', $hash{'thisvar'}, "\n"; $hash{'thisvar'} = param('webvar'); # modifies from form value untie %hash;
Of course, in your non-CGI program, you wouldnt be loading in the CGI module.

Naturally, you could also do something like this:
$filename = '/path/to/config/file'; open(CONF,"<$filename"); while(<CONF>){ chomp; my ($q, $w) = split(/\t/,$_,2); $config{$q} = $w; } close(CONF); $config{'variable'} = 'new contents'; open(CONF, ">$filename"); print CONF "$_\t$config{$_}\n" for keys %config; close(CONF);

Good luck,

Impossible! The Remonster can only be killed by stabbing him in the heart with the ancient bone saber of Zumakalis!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://469557]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2017-10-20 00:30 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (258 votes). Check out past polls.