读书人

perl处置properties文件

发布时间: 2012-10-14 14:55:08 作者: rapoo

perl处理properties文件

使用Config::Properties模块,详情请见:http://search.cpan.org/~salva/Config-Properties-1.70/Properties.pm

?

use Cwd;BEGIN {$ipath = getcwd . "/lib/perl/pm/";push @INC, $ipath;}use Config::Properties;my $properties = new Config::Properties();open PROPS, "< $propfile"or die "unable to open properties file";$properties->load(*PROPS);$value = $properties->getProperty( $key );# saving...open PROPS, "> $propfile"or die "unable to open properties file for writing";$properties->setProperty( $key, $val );$properties->format( '%s=%s' );$properties->store(*PROPS, $header );close PROPS;
?

读书人网 >perl python

热点推荐