The spurious error message appeared in 5.20 and got fixed in 5.38.
I think the following excerpt from the 5.38.0 perldelta is relevant here:
Syntax errors no longer produce "phantom error messages"
Generally perl will continue parsing the source code even after
encountering a compile error. In many cases this is helpful, for
instance with misspelled variable names it is helpful to show as m
+any
examples of the error as possible. But in the case of syntax error
+s
continuing often produces bizarre error messages and may even caus
+e
segmentation faults during the compile process. In this release th
+e
compiler will halt at the first syntax error encountered. This mea
+ns
that any code expecting to see the specific error messages we used
+ to
produce will be broken. The error that is emitted will be one of t
+he
diagnostics that used to be produced, but in some cases some messa
+ges
that used to be produced will no longer be displayed.
See "Changes to Existing Diagnostics" for more details.
Cheers, Rob |