in reply to Optimize file renaming.

chdir("e:\\perl\\comics\\"); foreach my $fname (glob("*.png")) { my $append = "0" x (7 - length($fname)); rename($fname, $append.$fname) or die "Cannot rename $fname"; }
Update:

in all honesty, for my usage I'd have written

perl -e 'rename($_,("0"x(7-length($_))).$_) for glob("*.png")'
from the appropriate directory

But it's probably best to maintain some readability when messing around with the filesystem

Update2:

rename($_,substr("000$_",-7)) is even groovier ( borrowed from EdwardG ), although it'll mess you up, if there are longer names, while the previous version won't