perl处理properties文件[转]

来源:互联网 发布:我的世界符文矩阵 编辑:程序博客网 时间:2024/06/05 16:27

perl处理properties文件

  • 博客分类: 
  • perl

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

 

Perl代码  收藏代码
  1. use Cwd;  
  2. BEGIN  
  3.     $ipath getcwd "/lib/perl/pm/" 
  4.     push @INC, $ipath;  
  5.  
  6. use Config::Properties;  
  7.   
  8. my $properties new Config::Properties();  
  9.   
  10. open PROPS, "< $propfile"  
  11.     or die "unable to open properties file" 
  12.       
  13. $properties->load(*PROPS);  
  14. $value $properties->getProperty( $key );  
  15.   
  16. saving...  
  17. open PROPS, "> $propfile"  
  18.     or die "unable to open properties file for writing" 
  19.   
  20. $properties->setProperty( $key, $val );  
  21.   
  22. $properties->format( '%s=%s' );  
  23. $properties->store(*PROPS, $header );  
  24.   
  25. close PROPS;  
 
0 0
原创粉丝点击