in reply to Re^4: Assigning to the CODE slot of a GLOB whose REF is held in a lexical?
in thread Assigning to the CODE slot of a GLOB whose REF is held in a lexical?

Scalar variables don't live on the symbol table. This works as advertised:

use strict; use warnings; our $bar = 1; # note the package variable my $barref = \*bar; *$barref = sub { "bar" }; print &{ *$barref }(), $/; print ${ *$barref }, $/; print *$barref{CODE}->(), $/; print ${*$barref{SCALAR}}, $/;

Update: no trouble at all. Hopefully it's a "learning experience." :-)

  • Comment on Re^5: Assigning to the CODE slot of a GLOB whose REF is held in a lexical?
  • Download Code

Replies are listed 'Best First'.
Re^6: Assigning to the CODE slot of a GLOB whose REF is held in a lexical?
by ikegami (Patriarch) on Nov 16, 2004 at 07:54 UTC
    I'll take that as a hint that I should be in bed. Sorry for the trouble!