String substitution in a number of files

Hello ..I have a bunch of txt files placed in a directory .The directory may have sub directories too.
I am trying to write a perl script that reads the txt files one by one and replaces the
string "BIO_HOME" to "BIOLOGY_HOME".

I have done a bit of perl programming before ..but I seem to have gone out of my depth here...especially
since I believe I have to use a bit of recursion here ( due to sub directories)...also I dont really understand
how to do the string substitution in the files .I have done string substitution opening individual files reading them and
then substituting them ..but I ma confused here

Could you please help me in here
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kim RyanIT ConsultantCommented:
This question come up often and has been answered before. Look at

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
use File::Find;
    return unless -f && -T;
    local @ARGV=($_);
    local $^I=""; #or ".bak" or "/backup/*" if you want a backup
    while( <> ){
If you are on a Unix box, you can simply do:

find /dir -name "*.txt" -exec perl -pi.bak -e 's/BIO_HOME/BIOLOGY_HOME/g' {} \;

find /dir -name "*.txt" -print0 | xargs -0 perl -pi.bak -e 's/BIO_HOME/BIOLOGY_HOME/g'

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.