in reply to Re^2: Can't bless
in thread Can't bless

Hi

Its has nothing to do with bless though, strict is protecting you from ambiguous code

$ splain < 2 perl -c packtest.pl Bareword "PENDULUM" not allowed while "strict subs" in use at packates +t.pl line 9 (#1) (F) With "strict subs" in use, a bareword is only allowed as a subroutine identifier, in curly brackets or to the left of the "=> +" symbol. Perhaps you need to predeclare a subroutine? packtest.pl had compilation errors (#2) (F) The final summary message when a perl -c fails.

ambiguous code (bareword PENDULUM)

$ perl -le" print bless {}, PENDULUM; " PENDULUM=HASH(0x3f9adc) $ perl -le" sub PENDULUM { 666 } print bless {}, PENDULUM; " 666=HASH(0x3f9adc)

See Ill-Advised Uses of Barewords in modern_perl_2016_a4.pdf page 167

Replies are listed 'Best First'.
Re^4: Can't bless
by ikegami (Patriarch) on Mar 22, 2021 at 08:19 UTC

    What they meant is that it's not clear from bless's docs that the second argument should be a string. Keep in mind that Perl does accept unquoted identifiers in a number of locations.

    Seeking work! You can reach me at ikegami@adaelis.com