in reply to Setting EUID & EGID in one step

Looks like it's something to do with your platform, because your case three works fine on OS X (10.3.5):

$ sudo perl -de 0 [ ... ] DB<1> x $>, $) 0 0 1 '0 262 80 31 20 5 4 3 2 1 0' DB<2> ( $>, $) ) = ( 501, "20 20 80" ) DB<3> x $>, $) 0 501 1 '20 80 20'