Sometimes, if you cannot understand the warnings that Perl is giving you, you can use diagnostics; which reveals a slightly more verbose version (with examples sometimes). Here's an abbreviated version of what diagnostics does in your code:
You used the syntax of a method call, but the slot filled by the object or package name contains an expression that returns a defined value....
Celebrate Intellectual Diversity
Comment on Re: Can't modify subroutine entry in scalar assignment