If you have perl subs/functions that can change the values of those variables, then you could do a callback to those subs/functions from within your XS code.
See 'perldoc perlcall' - especially the examples that are provided therein.
knows a better solution.