This is one area where the perldocs don't help much. But on most *nix systems you can 'man printf' or 'man sprintf' to get the relevant docs. Or find online Unix man pages.. or just give you the answer: 'printf("%06d", $variable)'
Ok, so I'm wrong, you can now find the relevant info with 'perldoc -f sprintf' or even here: sprintf.