in reply to How to create a parallel communication with 2 subroutine

I tried to fork the process in Subroutine A and called the subroutine B from the child but didn't worked.

You haven't shown how you tried using fork, so it's hard to tell why it failed...

Anyhow, here's a way using it that should fit your specs:

#!/usr/local/bin/perl -w use strict; use Time::HiRes qw(usleep time); sub doit { my $n = shift; printf STDERR "%.3f: $n. [$$] %s doing something...\n", time(), (caller(1))[3]; usleep(5e5); } sub A { doit(1); doit(2); doit(3); my $pid = fork(); die $! unless defined $pid; if (!$pid) { B(); exit; } doit(4); doit(5); kill 9, $pid; # stop parallel process wait; } sub B { doit(1); doit(2); doit(3); doit(4); doit(5); } A(); __END__ 1325026859.241: 1. [24625] main::A doing something... 1325026859.741: 2. [24625] main::A doing something... 1325026860.241: 3. [24625] main::A doing something... 1325026860.742: 1. [24626] main::B doing something... 1325026860.743: 4. [24625] main::A doing something... 1325026861.243: 2. [24626] main::B doing something... 1325026861.243: 5. [24625] main::A doing something... 1325026861.743: 3. [24626] main::B doing something...

(Of course, you could also send a less drastic signal than "9" to stop the other process.)