http://www.perlmonks.org?node_id=1011214


in reply to Replacing matches within string without splitting.

Typically, leading zero printing, and other formatting is done using sprintf and friends:
perl -E '$x="2,42,1,3"; printf "%.2d ",$_ for eval("($x)") ; print +"\n"' 02 42 01 03
Update: Replaced with better example.

             "By three methods we may learn wisdom: First, by reflection, which is noblest; Second, by imitation, which is easiest; and third by experience, which is the bitterest."           -Confucius