in reply to Re^2: DESTROY problem
in thread DESTROY problem

Here's something to ponder. Can you use a quoted string as a subroutine name? If you don't know, figure that out and then you will have your answer.

Replies are listed 'Best First'.
Re^4: DESTROY problem
by JavaFan (Canon) on Jan 01, 2011 at 19:36 UTC
    Can you use a quoted string as a subroutine name?
    Yes.
    sub foo {say "Hello"} "foo"->(); __END__ Hello
    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,
    $arrayref->[1];
    the arrow would be a binary operator with two array references on either side.

    Note that this works:

    sub Foo::foo {say "Hello"}; bless [], "Foo"->${\"foo"}; __END__ Hello