in reply to Formating Numbers Preceding 0's

sprintf "%06d", $defectid

See perldoc -f sprintf and perldoc -f printf.