http://qs321.pair.com?node_id=869377


in reply to Re^2: typeglob/symbolic reference question
in thread typeglob/symbolic reference question

Maybe this clarifies things?

sub bill { say 'hi' };; bill;; hi *bill = sub { say 'bye' };; Subroutine main::bill redefined at (eval 8) line 1, <STDIN> line 3. bill;; bye $x = 'bill';; *{$x} = sub { say 'hi again' };; Subroutine main::bill redefined at (eval 11) line 1, <STDIN> line 6. bill;; hi again

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^4: typeglob/symbolic reference question
by bduggan (Pilgrim) on Nov 04, 2010 at 16:58 UTC
    And also
    *{$x}{CODE}->() hi again
    Interesting that assigning to *{$x}{CODE} is not allowed.
    *{$x}{CODE} = sub { print "hi" }; Can't modify glob elem in scalar assignment...
      Interesting that assigning to *{$x}{CODE} is not allowed.

      If I recall correctly--which i quite possibly don't--there is a proper syntax for doing that.

      But, like many people I suspect, I went through the process of playing with globs many moons ago, trying all the different forms and syntaxes, and then promptly forgot most of them because the are so few occasions when they are useful.

      It's one of those dark corners of Perl that's good to know it exists for the rare occasions that a use for it pops up. But when (if) it does, I have to go off and look up the syntax.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.