Perl Read Configuration File
来源:互联网 发布:安装mysql步骤 编辑:程序博客网 时间:2024/04/30 10:50
#!/usr/bin/perl -w
use strict;
use English;
use Carp;
package ReadConfFile;
sub new
{
my $class = shift;
my $self = {};
bless ($self, $class);
return $self;
}
sub ReadConfFile
{
my ($self, $confFile ) = @_;
open( CONFFILE,"<$confFile" ) || die " File $confFile is not present";
my %keyValues;
foreach my $line(<CONFFILE>)
{
chop($line);
if ((!($line =~ /^(\s*#)/)) && ($line =~ /\w/ ))
{
$line =~ s/[ \t]+//;
my @pair = split ( /=/, $line );
$keyValues{$pair[0]} = $pair[1];
}
}
close(CONFFILE);
return %keyValues;
}
1;
__END__
[shengshu@cdling25 verifyPM]$
use strict;
use English;
use Carp;
package ReadConfFile;
sub new
{
my $class = shift;
my $self = {};
bless ($self, $class);
return $self;
}
sub ReadConfFile
{
my ($self, $confFile ) = @_;
open( CONFFILE,"<$confFile" ) || die " File $confFile is not present";
my %keyValues;
foreach my $line(<CONFFILE>)
{
chop($line);
if ((!($line =~ /^(\s*#)/)) && ($line =~ /\w/ ))
{
$line =~ s/[ \t]+//;
my @pair = split ( /=/, $line );
$keyValues{$pair[0]} = $pair[1];
}
}
close(CONFFILE);
return %keyValues;
}
1;
__END__
[shengshu@cdling25 verifyPM]$
- Perl Read Configuration File
- Perl read INI file
- log4j:ERROR Could not read configuration file [log4j.properties]
- log4j_ERROR Could not read configuration file [log4j.properties]
- File Read
- read file
- 1-Configuration Read
- JBossAS 6.1.0.Final启动报Unable to read the logging configuration from 'file:logging.properties'
- Loaded Configuration File (none)
- Example wpa_supplicant configuration file
- libconfig - Configuration File Library
- libconfig - Configuration File Library
- [log4j] log4j configuration file
- Weblogic Configuration File
- Sample ffserver configuration file
- Jboss log configuration file
- Read Config.xml in Perl
- Perl I/O Read & Write
- 线段树染色模板,用于颜色较少的情况。 POJ 2777
- leach和leach-c的比较
- Perl Perform DB Operations
- 页面自动关闭
- Bash Shell 字符串操作
- Perl Read Configuration File
- sqlserver事务与oracle事务
- 【命令提取】工具
- 30 岁? 25思考.......
- Perl Verify PMCoreBasedAD
- .net的组件
- HTML to Image in C#(C#实现Html转换为Image,即网页截图)
- 通过使用resetlog恢复控制文件恢复数据库
- 查询Oracle使用的特性