Ron Smith wrote:
> I'm trying to rename some files from the command line but nothing
> gets changed. I think I'm leaving out something; maybe '$_'. Or, I
> have incorrect syntax. I don't get any error message either. I took a
> look at 'man rename', but it doesn't show an example of a loop. I'm
> using the following on the command-line:    
> 
> perl -e 'for (`ls -1`) { rename filename, newfilename if /\w+$/}'
> 
> Can anyone show me the error of my ways?

What are you trying to do here? You're renaming a file called "filename" to
"newfilename" repeatedly.

'filename' and 'newfilename' are so-called 'barewords' here, and are treated
as strings in this context.

Perl has built-in globbing, so shelling to ls is not necessary.

Here's an article discussing the "classic" perl rename script. Why not start
with that?

http://www.evolt.org/article/Renaming_Files_with_Perl/17/351/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to