The easiest way to make a script run in the background is just by putting an & after the command (if you are using a standard unix shell).
If you want to make a program that backgrounds on its own, you should fork and then use the "setsid" command.
use POSIX qw(setsid);
exit if fork(); # parent dies
setsid; # make this a new process group
... rest of your program ...