Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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 cookies bake in the oven...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (10)
As of 2017-02-23 14:39 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (347 votes). Check out past polls.