Sometimes it's just a lot easier to use two regexes:
#!perl use warnings; use strict; while (<DATA>) { if ($_ =~ /^MONKS/ .. /}/) { #Range/flip-flop operator s/,2329,/,9999,/; } print; } __DATA__ LOSER () { echo "insert into monks values ('$1',sysdate,null,null,null,'OP',null, +'$8',23,$3);" >> $OPTHREE } MONKS () { echo "insert into monks values ('$1',sysdate,null,null,null,'OP',null +'$8',2329,$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 }
Check your docs for the range operator and its 'flip-flop' (scalar) context if the '/^MONKS/ .. /}/' gives you trouble.
In reply to Re: regex within an input file
by Art_XIV
in thread regex within an input file
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |