Excellent, this is exactly what I was looking for -- I don't even want to tell you how much time I wasted on trial and error.
And to add a $year field, that searches for four-digit numbers, would that just be some kind of grep? Perhaps something like ^\d\d\d\d$ this? Or does XML::Writer not have that capability?