in reply to no expected 'Useless use of a constant in void context' warning for expression in return statement

This warning is a compile-time warning; not a run-time warning. At compile time, perl cannot tell what contexts the function A() will ever be called in. If A() is ever called in list context (perhaps even from within another module that hasn't been loaded yet) then 10 won't be useless.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
  • Comment on Re: no expected 'Useless use of a constant in void context' warning for expression in return statement
  • Select or Download Code