if (my $pid = fork) { # $pid defined and !=0 -->parent
++$forkcount;
} else { # $pid==0 -->child
open my $IN, '<', $infile or exit(0);
open my $OUT, '>', "$tempdir/$subdir/text-$i" or exit(0);
while (<$IN>) {
tr/-!"#%&()*',.\/:;?@\[\\\]”_“{’}><^)(|/ /; # no punct "
s/^/ /;
s/\n/ \n/;
s/[[:digit:]]{1,12}//g;
s/w(as|ere)/be/gi;
s{$re2}{ $prefix{lc $1} }g; # prefix
s{$re3}{ $substring{lc $1} }g; # part
s{$re1}{ $whole{lc $1} }g; # whole
print $OUT "$_";
}
close $OUT;
close $IN;
defined $pid and exit(0); # $pid==0 -->child, must exit itself
}
####
my $pid=fork() // die "Can't fork: $!";
if ($pid) {
# parent code
} else {
# child code
}
####
my $pid=fork();
defined($pid) or die "Can't fork: $!";