in reply to Detach from terminal

I'd recommend taking a look at Proc::Daemon. It's fairly simple to use and makes sure that you are completely detached from any terminal.