SV* obj = newSViv((IV)soldier); SV* obj_ref = newRV_noinc(obj); sv_bless(obj_ref, gv_stashpv(class, TRUE)); SvREADONLY_on(obj); return obj_ref;