Maybe I'm missing something, but this Works For Me:
sub foo { "foo" } $fooref = \*foo; print *bar{SCALAR}; *bar = *$fooref{CODE}; print *bar{SCALAR}; print *foo{CODE}; print *bar{CODE};
Update: I just noticed you want to assign to a globref. This works too:
sub foo { "foo" } $fooref = \*foo; $bar = 1; $barref = \*bar; print *bar{SCALAR}; *$barref = *foo{CODE}; print *bar{SCALAR}; print *foo{CODE}; print *bar{CODE};
Another Update: assigning an anonymous coderef to the glob ref doesn't overwrite the scalar slot of the glob for me either:
$bar = 1; $barref = \*bar; print *bar{SCALAR}; *$barref = sub { "bar" }; print *bar{SCALAR};
In reply to Re: Assigning to the CODE slot of a GLOB whose REF is held in a lexical?
by revdiablo
in thread Assigning to the CODE slot of a GLOB whose REF is held in a lexical?
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |