system(@stuff) check_call($custom_message,@stuff); sub check_call { my $custom_message = shift; my @call = @_; # check for 0 return status return unless $?; # bugger, we have an error so tell all # Work out return code my $rc = $? >> 8; die qq! System call failed Error code $rc $custom_message Actual call was system( "@call" )!; }