note
nvivek
<p>Grep pattern used for getting files can be modified to reduce the for loop iteration as you're going to rename only file names which are less than or equal to 8 characters with .doc extension.</p>
<code>
@files = sort grep /^.{1,8}\.doc$/, readdir(DIR);
</code>
1019820
1019844