in reply to Zero Padding

You can do this just using sprintf: $padded = sprintf "%06d", 13; The zero after the percent sign says to pad with zeros instead of spaces.