![]() |
|
Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: Optimize file renaming.by blazar (Canon) |
on May 26, 2005 at 11:59 UTC ( [id://460627]=note: print w/replies, xml ) | Need Help?? |
Hint: sprintf
Update: Analyzing more precisely your script... It's better, for various reasons to long to be discussed here, to instead of -w. With recent enough perls, that is... Well, nothing wrong with this, per se. But I have the impression that people tend to abuse opendir & C. where a simple glob would do. In particular since you say that your script did work, you must have run it from e:\perl\comics. Otherwise you should have chdir'd there or prepended the dirname to the filenames subsequently. Also, and this is IMHO important, perl supports "/" as the directory separator also under Windows, which is useful. Quoting backaslashes can be confusing and may lead to errors. If you really want to use them, and of course if you don't need interpolation, you can use single quotes, which hopefully will make your life easier. All in all you may have had e.g.
Huh?!? Why reverse?!? Nothing wrong with this either, but a very useful module for "this kinda things" is File::Basename. Now I use it even when a simple regex would do. In any case it makes me sure it's doing the right thing. <snip rest of code> Don't! Use sprintf as hinted above, instead. All in all, if this was just a quick hack, I would have done that with a combination of shell cmds and perl, e.g.:
In Section
Seekers of Perl Wisdom
|
|