读取section1中键key1的值
#! perl
$ini = "test.ini";
$section = "section1";
$key = "key1";
# 打开文件
open( STDIN, "< $ini" ) || die "Cannot open file $ini\n$!\n\n$syntax";
while ( <STDIN> ) {
if ( $_ =~ m/^\[$section\]\s*\n([^\[][^\n]*\n)*?"?$key"?\s*=\s*"?([^\n]+)"?\s*(\n|$)/im ) {
print "\n\"$ini\"\n";
print "[$section]\n";
print "$key=\n";
}
}
# Close INI file
close STDIN;
日期:2020-04-11 23:04:31 来源:oir作者:oir
