Pattern Matching problem in UNIX

Hello All,

I need help I have a problem in searching the pattern in a file

let us say the file contains the below lines

line 1 USING *'/FILE/FOLDER/RETURN')
.................
.................
line 4 USING *'/FILE/FOLDER/6kdat1')
line 5 USING *'/FILE/FOLDER/4kdat1')
.................
.................
line 8 USING *'/FILE/FOLDER/TMPSPACE')
.................
line 9 USING *FILE '/FILE/FOLDER/TEST'100004)
.................
line 11 USING *FILE '/FILE/FOLDER/TEST'2000)
.................
.................
line 14 USING *FILE '/FILE/FOLDER/TEST'2000)
.................
line 16 USING *FILE '/FILE/FOLDER/TEST'3000)

Actually i want to search a pattern in the file, lets say USING *, if the pattern is found then get each line

for example the pattern is found in the following lines line 1,4,5,8,9,11,14,16

Then get each line and go to the end of the line and

check whether the line ends with a number say here in line 9,11,14,16 it ends with a number but with ) as the last character.

and replace the number with another input string.

Actually i tried lot of options in PERL but could not get a proper solution for this.

Can anyone please help in this regard.

Thanks

Rahul

awk -F"[')]"  '/USING \*/ && $3!~/[0-9].*/ ; /USING \*/ && $3~/[0-9].*/{sub($3,"Word"); print }'  filename
perl -pe 's/(.* USING .*\D)\d+\)/$1 something)/' file

The regular expression looks for anything (.*) followed by "USING" with spaces on both sides, followed by anything, followed by a non-number (\D). The parentheses capture this match into $1. Then outside the parentheses we look for a number with one or more digits (\d+) followed by a closing parenthesis (with a backslash, to match it literally). This is replaced with $1 followed by "something" (you didn't say what exactly) followed by a closing parenthesis.

It's not so much a Perl question as a regex question, really.