in reply to Assigning to the CODE slot of a GLOB whose REF is held in a lexical?
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};
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Assigning to the CODE slot of a GLOB whose REF is held in a lexical?
by ikegami (Patriarch) on Nov 16, 2004 at 07:35 UTC | |
by revdiablo (Prior) on Nov 16, 2004 at 07:38 UTC | |
by ikegami (Patriarch) on Nov 16, 2004 at 07:42 UTC | |
by revdiablo (Prior) on Nov 16, 2004 at 07:50 UTC | |
by ikegami (Patriarch) on Nov 16, 2004 at 07:54 UTC |