CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Unable to rename subdirectories recursively

 



kirk124
Novice

Aug 13, 2002, 9:24 AM

Post #1 of 2 (271 views)
Unable to rename subdirectories recursively Can't Post

Perl people:


I am trying to recursively rename files in my directory and subdirectories on my pc.

I noticed that I can rename files in my current directory but NOT in my subdirectories. I use the Find module.

Here is my code :

use File::Find;

my $host = d5573786;
my $new_string = 75219;

find sub {

if( $_ =~ m/(.*)$host(.*)/i)
{

my $concat = $1 . $new_string . $2;

if (rename($_ ,$concat)) {
print "it was successful \n";
}
else {
print "it was not successful \n";
exit();
}
}
},".";

I 've been getting lots of unsuccessful nessages.

Any inputs appreciated.

--Kirk


Paul
Enthusiast

Aug 13, 2002, 10:44 AM

Post #2 of 2 (269 views)
Re: [kirk124] Unable to rename subdirectories recursively [In reply to] Can't Post

Try adding $_ and $! into the error message to find out why.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives