Really_need_to_remodel
New member
$adf_file="file.xml";
$num_of_adfs=10;
my $replace_this = "email_replacement";
for ($count = 1; $count < $num_of_adfs; $count++) {
$newfile="test_".$month.$day.$year."_".$count;
my $with_this = "<email>".$newfile."@yahoo.com</email>";
$newfilename="test_".$month.$day.$year."_".$count.".adf";
copy($adf_file,$newfilename) or die "Copy failed of ".$newfilename;
open(INFO, $adf_file);
my @lines=<INFO>;
open(OUT,$newfilename) or die "Open failed of ".$newfilename;
foreach (@lines)
{ # read a line from file IN into $_
$_ =~ s/\b$replace_this\b/$with_this/g;
print OUT $_;
#s/$replace_this/$with_this/g; # change the lines
}
close (INFO);
close (OUT);
}
The above is my perl script. I make 10 copies of my template xml file I'm trying to replace the string "email_replacement" with a dynamic string that is "<email>[email protected]</email>. For some reason, the "email_replacement" string is never replaced. Please help.
$num_of_adfs=10;
my $replace_this = "email_replacement";
for ($count = 1; $count < $num_of_adfs; $count++) {
$newfile="test_".$month.$day.$year."_".$count;
my $with_this = "<email>".$newfile."@yahoo.com</email>";
$newfilename="test_".$month.$day.$year."_".$count.".adf";
copy($adf_file,$newfilename) or die "Copy failed of ".$newfilename;
open(INFO, $adf_file);
my @lines=<INFO>;
open(OUT,$newfilename) or die "Open failed of ".$newfilename;
foreach (@lines)
{ # read a line from file IN into $_
$_ =~ s/\b$replace_this\b/$with_this/g;
print OUT $_;
#s/$replace_this/$with_this/g; # change the lines
}
close (INFO);
close (OUT);
}
The above is my perl script. I make 10 copies of my template xml file I'm trying to replace the string "email_replacement" with a dynamic string that is "<email>[email protected]</email>. For some reason, the "email_replacement" string is never replaced. Please help.