Well, I didn't actually run the code myself. Thought I'd share what I did in case it helps others.
I just cut and pasted the OP's code into Padre. It marked the last two lines of code as having issues. When I moved my mouse over the next to last line, Padre showed the same error message that the OP listed. However, that line looked correct to me.
Here's the key part. From past experience, I figured that if the line that is indicated as having issues by the Perl interpreter, then I needed to check the line(s) before it. In my code, the cause has usually been missing semi-colon or I had opened a closure (single quotes, double quotes, square bracket, etc.) and failed to close the closure. Those two kinds of mistakes usually has caused the Perl interpreter to complain about an incorrect line number in my code.
Anyways, when I started checking the other lines of code, that's when I noticed the missing semi-colon.