Hi,
I want to rename all the files in a directory with filenames starting 1.jpg to n.jpg.
Why this code does not rename the files?
opendir(DIR, "/tmp") or die "can not open dir: $!\n"; my @files = grep {/.jpg/ } readdir(DIR); closedir(DIR);
my $count = 1;
foreach (@files){ print "@files\n"; # works: prints all the files my $new = $_; $new =~ s/(.*)(.jpg)/$count$2/;
rename($_, $new) or die "can not rename file: $!\n"; print "$_ renamed to $new\n"; $count++; }
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>