A quick and dirty way to have it detach and stay in the background is to fork(), and then have the parent exit. I have used this a few times in the past for some simple programs and haven't had any issues.
Here's a short example:
# do startup/initialization code
...
if (my $pid = fork()) {
print "Sending to background...\n";
exit(0);
}
...
# main application code here
Proc::Daemon pretty much does the same as this, but re-opens STDIN,STDOUT,STDERR and a few other things. You might want to check the source for that module, if you're interested. Also it's probably best to use that module if this is going to be production code. I just thought I'd show the non-module way (for learning purposes).