3

In XS, how do I turn a string that holds a variable name into its address, I want to do something like the following perl code:

our $var = 1;
print ${$main::{var}};
Chas. Owens
  • 64,182
  • 22
  • 135
  • 226

1 Answers1

9

In perlguts, it says:

If you know the name of a scalar variable, you can get a pointer to its SV by using the following:

SV*  get_sv("package::varname", FALSE);
Community
  • 1
  • 1
Axeman
  • 29,660
  • 2
  • 47
  • 102