in reply to Re^3: DESTROY problem
in thread DESTROY problem
Can you use a quoted string as a subroutine name?Yes.
The reason you cannot use a quoted string, or a general expression, is the limited amount of tokes that can follow an arrow. Based on token on the right hand side of an arrow, it's decided at compile time what kind of dereference it is. Think about it, if it where delayed till run time,sub foo {say "Hello"} "foo"->(); __END__ Hello
the arrow would be a binary operator with two array references on either side.$arrayref->[1];
Note that this works:
sub Foo::foo {say "Hello"}; bless [], "Foo"->${\"foo"}; __END__ Hello
|
|---|