What does the dollar sign mean, followed by the question mark in Perl?

Further in the Perl script:

$a=apple $b=orange if ($?==0) { # do something } 

What does $? mean $? ?

+8
perl
source share
4 answers

This is the state returned by the last operation of the system, pipe or reverse. See perlvar link.

+13
source share

$? , along with all other "magic" variables, is documented in the perlvar section of Perl files. Unless you actually have a Unix-like installation using the man command, you should also be able to google for man perlvar .

+10
source share

Others answered the question about the meaning of $? .

I also thought that you could also get help on special Perl variables on the command line:

 perldoc -v $? 

Depending on your shell, you may need to avoid $ .

perldoc -h

+5
source share

$? or $ CHILD_ERROR (if English is used) contains the status of the last blitz (or several ways to start a child process with Perl.) See perlvar for a full explanation.

+4
source share

All Articles