$ perl -Mdiagnostics -e " rand()->menu " Can't call method "menu" without a package or object reference at -e line 1 (#1) (F) You used the syntax of a method call, but the slot filled by the object reference or package name contains an expression that returns a defined value which is neither an object reference nor a package name. Something like this will reproduce the error: $BADREF = 42; process $BADREF 1,2,3; $BADREF->process(1,2,3); Uncaught exception from user code: Can't call method "menu" without a package or object reference at -e line 1. at -e line 1.