Set PL_uid, PL_euid, PL_gid, or PL_egid to the new values. In general, to see where built-in magic variables get their value, look at Perl_magic_get in mg.c.
When any of the variables are changed, perl also sets the low bit of PL_tainting on if the uid
is not 0 and either the euid differs from the uid or the egid differs from the gid. You may want to do this in your
code too.