in reply to Read from a header file like C
I'd store any other config stuff in the DB. Looks like the purpose is just to "get going" without having to modify the code itself.#!user/bin/perl use strict; use warnings; use Data::Dumper; use Config::Tiny; my $file=<<END; [DBname] Port Number = 1000 host name = abc01.xyz.com username = gvenkat password = ganesh99 END my $Config = Config::Tiny->new; $Config = Config::Tiny->read( \$file ); my $portnum = $Config->{DBname}->{'Port Number'}; print "$portnum\n"; my $hostname = $Config->{DBname}->{'host name'}; print "$hostname\n"; my $username = $Config->{DBname}->{'username'}; print "$username\n"; my $password = $Config->{DBname}->{'password'}; print "$password\n"; my $href = $Config->{DBname}; print Dumper $href; __END__ 1000 abc01.xyz.com gvenkat ganesh99 $VAR1 = { 'username' => 'gvenkat', 'Port Number' => '1000', 'host name' => 'abc01.xyz.com', 'password' => 'ganesh99' };
Update: I looked at the post from Your Mother at Re: Read from a header file like C. That seems to be the way to go for MySQL. Similar format to the above.
|
|---|