S
sivga
Hi all i need to search for a particular string and replace it in a
file
for eg :input file has
stock 3 99999 6 13456000 -market 1 100 5600 shift 2 rshit 36
stock 300 99999 6 13456000 -market 2 300 5700 shift 2 rshit 312
stock 31234 99999 6 13456000 -market 3 400 5700 shift 2 rshit 3675
stock 456 99999 6 13456000 -market 4 200 5800 shift 2 rshit 30
......
99999 in the above lines needs to be replaced with 77777 so the o/p
after replace will be
stock 3 77777 6 13456000 -market 1 100 5600 shift 2 rshit 36
stock 300 77777 6 13456000 -market 2 300 5700 shift 2 rshit 312
How do i do this ?
This does not seem to work ..
while ($line = <AG>) {
if ($line =~ /stock[ ]+([99999])*/ ) {
print " The stock is $line";
$line =~ s/stock[ ]+([99999])*/stock[ ]+([77777])*/;
}
}
Thanks for the help
file
for eg :input file has
stock 3 99999 6 13456000 -market 1 100 5600 shift 2 rshit 36
stock 300 99999 6 13456000 -market 2 300 5700 shift 2 rshit 312
stock 31234 99999 6 13456000 -market 3 400 5700 shift 2 rshit 3675
stock 456 99999 6 13456000 -market 4 200 5800 shift 2 rshit 30
......
99999 in the above lines needs to be replaced with 77777 so the o/p
after replace will be
stock 3 77777 6 13456000 -market 1 100 5600 shift 2 rshit 36
stock 300 77777 6 13456000 -market 2 300 5700 shift 2 rshit 312
How do i do this ?
This does not seem to work ..
while ($line = <AG>) {
if ($line =~ /stock[ ]+([99999])*/ ) {
print " The stock is $line";
$line =~ s/stock[ ]+([99999])*/stock[ ]+([77777])*/;
}
}
Thanks for the help