sanku has asked for the wisdom of the Perl Monks concerning the following question:

hi monks, I have a small programs at about 200 programas in a single folder. In each files i have to change the path form /171/ to /mmt/171/. Is it possible to done it with perl file handling. An suggestions regarding this. Thanks in advance.

Replies are listed 'Best First'.
Re: path changing problem
by apl (Monsignor) on Apr 01, 2008 at 12:12 UTC
    Do you mean you wish to move all files from directory /171 to directory /mmt/171 ?

    Or do you mean you wish each program to be modified so that references to directory /171 are changed to directory /mmt/171?

    These are two very different questions. Or do you mean something else entirely?

Re: path changing problem
by lidden (Curate) on Apr 02, 2008 at 07:48 UTC
    I think you want something like this:
    perl -wi.bak -pe 's!/171/!/mmt/171/!' /path/to/dir/*

    Delete .bak files when you have confirmed that it did what you wanted.