kkurnala has asked for the wisdom of the Perl Monks concerning the following question:

Dear Perl Monks, I am a novice in perl and currently stuck with a problem. please help. My code has lines like:

}elsif ($branchurl =~ /sites/) { $outfile_merge = 'STARTING MERGE FOR sites\n================== +================\n'; $branchurl =~ /sites\/(.+)\/branches/i; print "$1"; $outfile_merge = `cd trunk/sites/$1; svn merge --dry-run $bran +churl .`; print " 5 - $outfile_merge\n"; }

In the above snippet, I want to know if there is an error with the cd command or svn merge command and come out of the loop with a error message Can one of you recommend what best I can do please? Thanks a tonne !!

  • Comment on How to know the exit status of sub-commands running with backticks in Perl.
  • Download Code

Replies are listed 'Best First'.
Re: How to know the exit status of sub-commands running with backticks in Perl.
by ikegami (Patriarch) on Apr 05, 2012 at 21:55 UTC

      can you please explain a little more? Thanks :)

        You may wish to read perlvar in addition to the system documentation already mentioned. Search for $?.

        Note too that if backticks fails it will set the special variable $!.

        True laziness is hard work