Hi,
Here's a simple script that is suppose to read a file and
changes a particular string.
sub ChangeVMConfFile{
open(DATA, "+<Test.txt") || die "Unable to open file" ;
while(<DATA>){
if ($_ =~m/Ethernet0.connectionType/){
$_ =~
s/Ethernet0.connectionType/Ethernet0.connectionType_changed/g ;
print DATA $_ ;
}
}
close(DATA) ;
}
What is happening is its appending the result on the original
file.I just one that line to be changed ?
Please let me know what I am doing wrong.
Thanx,
Alok.
--Initial file----
uuid.action = "create"
Ethernet0.connectionType = "bridged"
Ethernet0.vnet = "VMnet2"
Output file-------
uuid.action = "create"
Ethernet0.connectionType = "bridged"
Ethernet0.vnet = "VMnet2"
uuid.action = "create"
Ethernet0.connectionType = "bridged"
Ethernet0.connectionType_changed = "bridged"
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>