Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^3: typeglob/symbolic reference question

by BrowserUk (Pope)
on Nov 04, 2010 at 01:11 UTC ( #869377=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://869377]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2020-11-01 01:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (291 votes). Check out past polls.

    Notices?