in reply to Re^2: File::Find and replacing spaces in filenames.
in thread File::Find and replacing spaces in filenames.
2. like this return 1 if $_ !~ /\s+/; ?
No, because then you would have to perform a second match, which is unneeded. The s// operator returns the number of substitutions made, and 0 is perl's value for false.
if ($_ =~ s/ /_/g) { # rename } else { return 1 }
However, according to the docs for File::Find the return value of the wanted() function is ignored, so just write:
if ($_ =~ s/ /_/g) { # rename }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: File::Find and replacing spaces in filenames.
by Kyshtynbai (Sexton) on Dec 22, 2012 at 20:03 UTC | |
by 7stud (Deacon) on Dec 23, 2012 at 03:29 UTC |
In Section
Seekers of Perl Wisdom