in reply to Detach from terminal

Not clear from your description, but it sounds like a shell issue, not a Perl issue. Try starting the program with, e.g., nohup myscript.pl &. You can read about nohup in the documentation for your particular shell.