perl中替换文本一例

perl中替换文本一例,第1张

概述由于工作需要,需要批量建立网站,修改配置文件。开始时用sed去批量修改的,最后改装成perl了。 #!/usr/bin/perl while(<>){ chomp; @line=split(/\s+/,$_); open FH,"< /home/test/$line[0]/wp-config.php"; my @webfile; while(<FH>){         s/(ME|ER)', ' 由于工作需要,需要批量建立网站,修改配置文件。开始时用sed去批量修改的,最后改装成perl了。 #!/usr/bin/perl
while(<>){
chomp;
@line=split(/\s+/,$_);
open FH,"< /home/test/$line[0]/wp-config.php";
my @webfile;
while(<FH>){
        s/(ME|ER)','root/$1','$line[1]/g;
        push @webfile,$_;
}
close FH;
open FH,"> /home/test/$line[0]/wp-config.php";
print FH for @webfile; #相当于foreach $mm (@webfile){                                #     print FH $mm;                                         #                                    #       }
close FH;

}
输入的文件 域名      数据库名称 a1.com       a1_db a2.com        a2_db 总结

以上是内存溢出为你收集整理的perl中替换文本一例全部内容,希望文章能够帮你解决perl中替换文本一例所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1288728.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-09
下一篇2022-06-09

发表评论

登录后才能评论

评论列表(0条)

    保存