ls | perl -lne '$suf=substr($_,6); rename $_, "XXXXX-$suf"'
When you use a shell loop, the
mv forks once per file. Perl's
rename command does not.
(Perl's rename command has some restrictions, but in this specific case those restrictions don't apply.)
As for the
rename command shown earlier, yes that works, but then you have all that confusion between two different kinds of rename and so on. If you have the right one, great, but if not, this works too.
If you don't have the perl-rename command and can't install it, you can just do this:
ls | perl -lne '$old=$_; s/(\w+)/XXXXX/; rename $old, $_'
As you can see, this uses the same substitution shown in the top answer. Of course the perl-rename has other bells and whistles (the top answer mentioned,
-n already, then there's
-f, and so on), and the more of them you need, the more you should install that instead of rolling your own in this manner.