I am working on something where i need to search and replace many variable names of a program.

For example,
I have a class Hello and its public variable is world, but the variable world has been changed to earth so now in the program i need to go and replace the world variable with earth. this is just one example but there are many different variables to be replaced.

Hello.world replace by 

variables to be replaced. code ..... Hello.world replace by Hello.earth code ....

so far i have a 2D array with old variable name and new variable name

but i am not able to find the strings such as world since it is in a single word Hellol.world

Please help on how to look for world in AnyClassName.old_VariableName and replace it by AnyClassName.new_VariableName

Thank You...


exactly. And if you have to read in multiple files, I would suggest you use:

undef ($|);

which will suck the entire file into a variable for replacement.

Alright, I know I'm not supposed to back post. But I realized my suggestion was incorrect (sorry, still getting the hang of this). I meant $/ not $|.


which will set the end of record to end of file. Then you can suck the entire file into a variable for replacement.