Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8235413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:48:07+00:00 2026-06-07T18:48:07+00:00

Possible Duplicate: perl “dollar sign and question mark” question I am trying to understand

  • 0

Possible Duplicate:
perl “dollar sign and question mark” question

I am trying to understand the Perl script written by someone. I don’t understand the use of $? in the script. Can anyone explain me the purpose of below line?

 system( "perform_task.sh", "-param1");
    if( ( $? >> 8 ) != 0 ) {
       print( "perform_task.sh failed " );
    } 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T18:48:08+00:00Added an answer on June 7, 2026 at 6:48 pm

    To find the meaning of any variable, you can either type

    $ perldoc -v '$?'

    on the command line with relatively recent versions of Perl or scan perldoc perlvar installed on your computer. Usually, it is best to read the documentation for the specific version of perl you have, but in a pinch, bearing in mind any possible gotchas due to version differences, the online version will do as well: perldoc -v ‘$?’:

    The status returned by the last pipe close, backtick (``) command, successful call to wait() or waitpid(), or from the system() operator. This is just the 16-bit status word returned by the traditional Unix wait() system call (or else is made up to look like it). Thus, the exit value of the subprocess is really ($? >> 8), and $? & 127 gives which signal, if any, the process died from, and $? & 128 reports whether there was a core dump.

    Further information can be gleaned from the documentation for perldoc -f system:

    If you’d like to manually inspect “system”‘s failure, you can check all possible failure modes by inspecting $? like this:

       if ($? == -1) {
           print "failed to execute: $!\n";
       }
       elsif ($? & 127) {
           printf "child died with signal %d, %s coredump\n",
               ($? & 127),  ($? & 128) ? 'with' : 'without';
       }
       else {
           printf "child exited with value %d\n", $? >> 8;
       }
    

    While there is nothing wrong with asking even elementary questions on Stackoverflow, if you actually want to become a capable programmer, you’ll need to get into the habit of reading the documentation yourself, and develop the capacity to understand it yourself.

    Otherwise, you’ll waste valuable time you could be using to solve problems instead on waiting for others to read the documentation for you.

    It really doesn’t affect the rest of us if you choose never to expend any effort in trying to understand documentation, but it will hurt you in the long run.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Why am I getting an “Out of memory” error with Perl's XML::Simple?
Possible Duplicate: Comparing Two Arrays Using Perl I am trying to find elements that
Related/Possible duplicate: How can I validate dates in Perl? I have created a script
Possible Duplicate: How do you create a Perl module? I have the script that
Possible Duplicate: How can I iterate through nested arrays in Perl? I am trying
Possible Duplicate: Reverse “Hello World” in Java How to print the reverse of a
Possible Duplicate: How do I perform a Perl substitution on a string while keeping
Possible Duplicate: How can I understand nested ?: operators in PHP? Why does this:
Possible Duplicate: Comparing Two Arrays Using Perl How can I print values which exist
Possible Duplicate: How can I take screenshots with Perl? How can I take a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.