Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Rename FILE to nnn-FILE

by saskaqueer (Friar)
on Dec 30, 2004 at 07:02 UTC ( [id://418200]=note: print w/replies, xml ) Need Help??


in reply to Rename FILE to nnn-FILE

For what it's worth, here's how I'd probably have written it (something like this anyhow). I'm not too sure about the glob. I've heard about how it's better to use the opendir/readdir combo, so I'm not too sure what to think of that.

#!perl -w use strict; chdir('bar') or die("chdir() failed: $!\n"); my $cnt; rename( $_, sprintf('%03d-%s', ++$cnt, $_) ) or warn("rename() failed: $!\n") for ( grep { ! /\A\./ } glob('*') );

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://418200]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-03-29 12:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found