Monday, November 23, 2009

Perl 定義ファイルの例と使い方

---定義ファイルの例
# Mysql DB Configure
DB_HOST = 'localhost'
DB_USER = 'test'
DB_PASSWORD = 'test1234'
DB_DATABASE = 'test'
----

#!/usr/bin/perl
open (CONF,"dbs.conf") || die "cannot open conf file!";
while () {
$_ =~ s/\#.*//g;
if ($_ =~ /'.*'/) {
/(\S+).*=.*\'(\S+)\'/;
${lc($1)} = $2;
}
}
close (CONF);

No comments: