I need to only change the nubmer 2329 to 9999 under the monks part and re write it to the same file so my Output should contain the MONKS part as follow:LOSER () { echo "insert into monks values ('$1',sysdate,null,null,null,'OP',null, +'$8',23,$3);" >> $OPTHREE } TEST () { echo "insert into monks values ('$1',sysdate,null,null,null,'OP',null, +'$8','$5',9,$2,$4,$3);" >> $OPTHREE # the following line should remain unchanged echo "insert into monks values ('$1',sysdate,null,null,null,'OP',null, +'$8',2329,$3);" >> $OPTHREE } MONKS () { echo "insert into monks values ('$1',sysdate,null,null,null,'OP',null, +'$8',2329,$3);" >> $OPTHREE }
I am doing the following but not getting the result I want it just not chanigning the value , can someone help:MONKS () { echo "insert into monks values ('$1',sysdate,null,null,null,'OP',null, +'$8',9999,$3);" >> $OPTHREE }
thanksuse strict; use warnings; my $text = do { local $/; <DATA> }; $text =~ s/(MONKS[\s\(\)]+{.*?,\s*?)2329(\s*?,[^}]*})/${1}9999${2}/sg; print "$text";
janitored by ybiC: Retitle from "exreg within an input file" for better searching
In reply to regex within an input file by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |