http://qs321.pair.com?node_id=603869


in reply to open a browser from the command line, wait a few seconds, and shut it. (ie, translate forking from bash to perl)

use IPC::Open2 qw( open2 ); my $pid = open2(my $to_child, my $from_child, 'konqueror', $url); sleep(5); kill(TERM => $pid);

Since we don't care about pipes, the above boils down to

my $pid = fork(); if (!defined($pid)) { die("Unable to fork: $!\n"); } if (!$pid) { exec('konqueror', $url); die("Unable to exec: $!\n"); } sleep(5); kill(TERM => $pid);

Don't forget to cleanup zombies using waitpid.

Update: Added second snippet.
Update: Oops! I was using kill($pid, TERM);. Thanks, Fletch.