| Michael Alipio 2007-01-23, 10:00 pm |
| Hi,
I have a directory which contains several files.
client1-2006-05-19.log.gz
client1-2006-05-20.log.gz
client1-2006-07-29.log.gz
client1-2006-10-05.log.gz
client1-2006-05-21.log.gz
I want strip all of "axisglobal-" in their filenames.
What I did was:
#!/usr/bin/perl
use warnings;
use strict;
use File::Find;
find (\&renamefiles, './');
sub renamefiles{
(my $newname) = $_ =~ s/^\w+-//g;
#rename ($_, $newname);
print $newname;
}
When I try printing the $newname which supposedly will print only "2006-N-N.log.gz", it instead prints a scalar value of 1, as if parenthesis around "my $newname" does not exists. And so, uncommenting the "rename" did do anything to myfiles.
Any explanation to this?
Do you have a perl one-liner to rename all files into their filenames with stripped "^\w+"... thanks.
Thanks.
________________________________________
________________________________________
____
Do you Yahoo!?
Everyone israving about the all-new Yahoo! Mail beta.
http://new.mail.yahoo.com
|