in reply to Setting the primary group from within a script

setpgrp 0, $pgrp;

See perldoc perlfunc or any perl reference for details. This is a rather unportable function in its details, but should work for you.

After Compline,
Zaxo