While this can certainly be achieved in Perl, I would suggest that this is not recommended practice (unless there is a pressing need for such privileges) - Typical practice for a daemon is to drop security privileges as soon as possible so that should an exploit in the daemon package be discovered, the risk of harm is minimised.
For a discussion on securing and locking down daemon processes, this article may be of interest.
In addition to the POSIX module to which you have been directed above by dbp, I would recommend your having a look at the real and effective user ID variables ($<, $>, $( and $)) listed in perlvar. Note that these variables can only be set, changing the corresponding process user ID variables, on machines supporting the associated set[re][ug]id() routine.
perl -le 'print+unpack("N",pack("B32","00000000000000000000000111110011"))' | [reply] [d/l] [select] |
Check out the POSIX module. It has setuid, setpgid, and setsid subs. There is also a setpgrp function built into Perl. | [reply] |