sfink has asked for the wisdom of the Perl Monks concerning the following question:
Here's what I have now:
(hopefully I didn't mess that up when modifying it for posting.)static void alias(char* dest_package, char* dest_name, char* src_package, char* src_name) { HV* src_stash = gv_stashpv(src_package, 0); SV* src_glob = *hv_fetch(src_stash, src_name, strlen(src_name), 0); HV* dest_stash = gv_stashpv(dest_package, 0); SV** dest_globP = hv_fetch(dest_stash, dest_name, strlen(dest_name), + 1); SV* dest_glob; if (dest_globP) { dest_glob = *dest_globP; } else { // WHAT GOES HERE? dest_glob = ...; } SvSetMagicSV(dest_glob, src_glob); }
I know I could do this by constructing the string "*dest_package::dest_name = *src_package::src_name" and passing it to eval_pv, and I may end up doing it that way, but for my own education if nothing else I'd love to know how to do this.
Oh, and are my final arguments to hv_fetch correct? I'm not sure when you should set the lval attribute to true.
|
|---|