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 6698865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:37:42+00:00 2026-05-26T06:37:42+00:00

I can do the following in bash: output=`command` retcode=$? Is there any way to

  • 0

I can do the following in bash:

output=`command`
retcode=$?

Is there any way to do the same in Perl? Something like this:

$output=`command`
$retcode=???
  • 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-05-26T06:37:42+00:00Added an answer on May 26, 2026 at 6:37 am

    You can read the $? variable (as in the shell). From man perlvar

     $?      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.  (Mnemonic: similar to sh and ksh.)
    
                   Additionally, if the "h_errno" variable is supported in C, its value is returned via $? if any "gethost*()" function fails.
    
                   If you have installed a signal handler for "SIGCHLD", the value of $? will usually be wrong outside that handler.
    
                   Inside an "END" subroutine $? contains the value that is going to be given to "exit()".  You can modify $? in an "END"
                   subroutine to change the exit status of your program.  For example:
    
                       END {
                           $? = 1 if $? == 255;  # die would make it 255
                       }
    
                   Under VMS, the pragma "use vmsish 'status'" makes $? reflect the actual VMS exit status, instead of the default emulation of
                   POSIX status; see "$?" in perlvms for details.
    
                   Also see "Error Indicators".
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On the Windows command line and cygwin bash I can execute the following without
How can I localize output of date command in MacOSX bash environment? for example,
Can I embed the following bash shell code: for name in $(git diff --name-only
I want to run the following bash command in Python 3: ls -l I
I want to input a string through command line to bash script and output
i need a bash script for mac osx working in this way: ./script.sh *
Can anybody explain why the following c-style loop in a bash script doesn't work
I have the following code example below. Whereby you can enter a command to
How can the following function be implemented in various languages? Calculate the (x,y) point
How can the following simple implementation of sum be faster? private long sum( int

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.