On Jan 9, 2006, at 11:02 AM, Jeremy White wrote:

Is there a way to get hold of the SV for $variable and manipulate it via XS?

Since it's a lexical, no. You can probably get away with an xsub that returns a reference to an SV allocated and stored in your XS file, like this:

  Foo.xs -=-=-=-=-=-=-=-=-=-

  static SV * the_foo;

  MODULE = Foo PACKAGE = FOO

  SV * get (class)
      CODE:
          if (!the_foo)
              the_foo = newSV ();
          RETVAL = newRV (the_foo);
      OUTPUT
          RETVAL

  # more functions that use the_foo

  Foo.pm -=-=-=-=-=-=-=-=-=-=-

  {
      sub mysub {
          my $fooref = Foo->get;
          $$fooref = "foo!";
      }
  }

--
"Ears! They help us -- Ears! They help us hear th-- Ea--E--E--E-- Ears!"
  -- A Sesame Street singing toy, with Yvonne gleefully pressing
    the button over and over and over and over and...

Reply via email to