in reply to How to change referent of lexical reference?

So it turns out what I want can be done like this in XS:
void
substitute_ref(ref1, ref2)
     SV* ref1
     SV* ref2;

     PPCODE:
       sv_unref(ref1);
       ref1 = ref2;

Yep, it's that simple. Still, I wish I could do it from pure Perl.
  • Comment on Re: How to change referent of lexical reference?

Replies are listed 'Best First'.
Re: Re: How to change referent of lexical reference?
by autarch (Hermit) on Oct 04, 2003 at 18:53 UTC
    Doh, this didn't work, I was just confused.

    I think that the only way to do this is to somehow make the underlying SVs point to the same hash structure, but I don't know how to do that safely (memory-wise), and Perl certainly has no API for this.