簡體   English   中英

修改Linux配置文件(perl)更簡單嗎?

[英]It simpler to modify the Linux configuration file (perl)?

有這種類型的linux配置文件:

[header1]
key1=var1

[header2]
key2=var2

如何將變量從var1更改為var1new並立即編寫Changes(在沒有key1的情況下創建它)?

使用Config::Tiny

use strict;
use warnings;

use Config::Tiny;

my $file = 'file.conf';

my $config = Config::Tiny->read($file);

$config->{header1}{key1} = 'var1new';

$config->write($file);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM