fork in perl

Can someone tell me perl fork example please. I tried online but could not get proper documentation.

https://wiki.bc.net/atl-conf/pages/viewpage.action?pageId=20548191

#! /usr/bin/perl
use warnings;
use strict;

my $x = fork;

if ($x) {
    for (1..5) { print "Parent\n"; sleep 1 }
} else {
    for (1..5) { print "Child\n"; sleep 1}
}

When you run this script, you'll see output as

$ ./test.pl
Parent
Child
Parent
Child
Child
Parent
Child
Parent
Parent
Child

The process has been forked here and "Parent" and "Child" will be printed together.

The order in which it is printed, i.e., "Parent" and then "Child" or "Child" and then "Parent" depends on how your OS schedules the forked processes.