die "fork: $!" unless (defined(my $pid = fork)); if ($pid) { say 'Hello from parent process'; } else { say 'Hello from child process'; }