#! /usr/bin/perl -T use strict; use warnings; $ENV{"PATH"} = ""; chdir "/home/user/"; chomp($update_location); # $update_location is: # /home/user/test/update_test.pl # it's retrieved from the database my $cmd = sprintf("perl %s", $update_location); system($cmd); if ($? == -1) { logger("failed to execute: $!\n"); # logger is a simple sub that appends whatever is passed # to an error.txt file } elsif ($? & 127) { logger("child died with signal coredump\n"); } else { my $sys_code = $? >> 8; logger("child exited with value $sys_code\n"); }