in reply to Loop or sub routine

It's not altogether clear to me what you want, but it seems sprintf may be the answer:

$bob_count_fixed = sprintf '%06d', 150;

will generate a six digit number with leading zeros.

True laziness is hard work