/* assume "buffer" is a C struct */ /* assume "package" is a perl string naming the package to bless the object in */ SV* self = newSViv(PTR2IV(buffer)); SV* ref = sv_bless(newRV_noinc(self),gv_stashsv(package,1)); /* ref is now a perl object containing a pointer to the "buffer" struct */