while(){ s/9999/YYYY/; # 4-char year first s/(?<=[^9])99(?=[^9])/MM/; # month is always in the middle s/(?