#!/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){
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;
}
close FH;
}
输入的文件
a1.com a1_db
a2.com a2_db