in reply to strings->can->isa but numbers->can't?

Elsewhere, Perl will stringify when it wants a string. There's no good explanation as to why it doesn't do that here.
  • Comment on Re: strings->can->isa but numbers->can't?

Replies are listed 'Best First'.
Re^2: strings->can->isa but numbers->can't?
by Anonymous Monk on Apr 26, 2012 at 18:13 UTC

    Elsewhere, Perl will stringify when it wants a string. There's no good explanation as to why it doesn't do that here.

    Sure there is, 3 is not a valid package or subroutine, name

    $ perl -le " package 3; " syntax error at -e line 1, near "package 3;" Execution of -e aborted due to compilation errors. $ perl -le " $3::3 " Bareword found where operator expected at -e line 1, near "$3::3" (Missing operator before ::3?) syntax error at -e line 1, near "$3::3 " Execution of -e aborted due to compilation errors. $ perl -le " sub 3 { 3 } " Illegal declaration of anonymous subroutine at -e line 1.
      But, interestingly
      perl -le "*3 = sub { 4 };print 3->()" 4