To execute something in the background, you can use system
:
#!/usr/bin/env perl
use strict;
use warnings;
system q(emacs &);
print "hello";
This will open emacs in the background and print "hello" straight away. If you removed the &
in the command it would wait for emacs to close before printing "hello".
As pointed out by @Brad in the comments, note that this will only work on systems where the shell understands the &
. If you were running on Windows for example, you would have to change the system
line to something like this:
system q(start /b program.exe);
See the system documentation for more details.