in reply to how to detect background process completed or not

Using the CPAN module Proc::Background, you should be able to write something like ..
use Proc::Background; my $proc = Proc::Background->new( $cmd ); $proc->wait; # wait for completion
Maybe a case of cracking a nut with a sledgehammer for this example, but it'd seem nice and clean, and to do what you need.

Hope that helps ..