in reply to Using sprintf in regular expreession.
Rather than using regular expressions and substitution you could split on hyphens into a list which you then slice into the order required. Pass the re-ordered items through a map in which you apply the sprintf and then join it all up again. Perhaps a bit more long winded but, to my eyes, a little easier to see what's going on.
johngg@abouriou:~/go$ perl -Mstrict -Mwarnings -E 'say q{}; my $date = q{3-15-1932}; $date = join q{-}, map { sprintf q{%02d}, $_ } ( split q{-}, $date )[ 2, 0, 1 ]; say $date;' 1932-03-15
I hope this is of interest.
Cheers,
JohnGG
In Section
Seekers of Perl Wisdom