in reply to Prepending 0's to 1000
You will find good use of the printf/sprintf functions.
perl -e "printf('%04d', 33)" [download]
__OUTPUT__ 0033