xywuyiba6 发表于 2017-5-17 12:01:08

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;
 
页: [1]
查看完整版本: perl处理properties文件