You simplified it a lot by dropping $maxdigs. Put that back in and I doubt you'll have saved more than a keystroke or two. :) But thanks for the substr method; I like that.
substr("0000$1",-4)
sprintf"%04.4d",$1
substr("0"x$maxdigs.$1,-$maxdigs)
sprintf"%0$maxdigs.$maxdigs"."d",$1
When I saw the name chip, I wondered if it was you. Welcome to Perl Monks! I've run into your work many times and have been impressed.
If you know you don't need extra leading zeros, then you can also get away with:
grep{s/(^|\D)0+(\d)/$1$2/g,1} sort
grep{s/(\d+)/sprintf"%06.6d",$1/ge,1} @sects;
Man, I shouldn't attempt this much thinking before breakfast.