T_TIED_HASH { SV* tie = NEWSV(0, 0); HV* hash = newHV(); /* Get a blessed reference to the pointer, */ sv_setref_pv(tie, CLASS, (void*)$var); /* and tie it to a hash. */ hv_magic(hash, (GV*)tie, PERL_MAGIC_tied); $arg = newRV_noinc((SV*)hash); }