Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

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]
[Discipulus]: ok boring meeting time is arriving.. fortunaltely the boss is in videoconference so i read Le Monde Diplomatique.. see you
[karlgoethebier]: ok no meetings no more. i go to my research kitchen...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (13)
As of 2017-05-24 09:16 GMT
Find Nodes?
    Voting Booth?