in reply to Problem with perlcritic when using Moose object

It is important to mention the Perl version that you are using. In Perl 5.26.2 MSWin32-x64-multi-thread I receive different compilation errors then yours.

E.g. Experimental shift on scalar is now forbidden at ... line .., near "shift ;"

I believe the error is cause by the contents of $hash and you are not showing the contents which makes it hard to understand the problem you are looking at. Also, the actual shift operation that causes the problem is not shown in your example code. The error you mentioned does not show where it is coming from.

And AFAICS there is no problem in your example code except for the fact that I personally would never use hash keys and method names that belong to the base instruction set of the Perl programming language.

  • Comment on Re: Problem with perlcritic when using Moose object

Replies are listed 'Best First'.
Re^2: Problem with perlcritic when using Moose object
by bangor (Monk) on Oct 04, 2018 at 15:42 UTC
    I don't think it is caused by the contents of $hash as the same error is reported when $Person->shift('one') is called.

    I think it is caused by the use of the keyword 'shift', and it is picked up by perlcritic as an attempt to dereference. And yes, I would never use that as a hash key either - note: I didn't write this code