【发布时间】:2015-05-30 12:04:24
【问题描述】:
我需要能够运行一个 perl 脚本来搜索和替换 [ RemotePhoneBook0 ] 下的 3 行
所以这里是文件的摘录:
[ RemotePhoneBook0 ]
path = /config/Setting/Setting.cfg
URL =
Name =
[ RemotePhoneBook1 ]
path = /config/Setting/Setting.cfg
URL =
Name =
我无法触摸 [RemotePhoneBook1]。当我完成后,上面的相同摘录应该如下所示:
[ RemotePhoneBook0 ]
path = /somePath/to/someDir
URL = someUrl
Name = someName
[ RemotePhoneBook1 ]
path = /config/Setting/Setting.cfg
URL =
Name =
s/^<<<what can i put here>>>\s*=.*/somePath/;
s/^<<<what can i put here>>>\s*=.*/someUrl/;
s/^<<<what can i put here>>>\s*=.*/someName/;
【问题讨论】:
-
您执行类似this 的操作,匹配
RemotePhoneBook0,然后阅读和编辑接下来的三行。 -
它看起来像一个ini文件。看看metacpan.org/pod/Config%3a%3aIniFiles
标签: perl