So, tracing the value back, $mon
gets a value of -1 on line 35, which means it was numerically 0 from line 30. My guess, since you don't have warnings
on, is that your content is different than you think going back to line 26, and so $mon
is undefined going into the decrement. Can't be sure without you input file, but based on what you've posted, I'm guessing the split on 29 splits on the T in MessageDateTime
rather than the T in the iso date.
See Basic debugging checklist and Use strict warnings and diagnostics or die.
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.