tweakmy
tweakmy

Reputation: 111

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

In the following in Perl script:

$a=apple
$b=orange

if ($?==0) {
  # do something
}

What does $? mean here?

Upvotes: 10

Views: 12263

Answers (4)

toolic
toolic

Reputation: 62037

Others have answered the question about the meaning of $?.

I thought I would also mention that it is also possible to get help on Perl's special variables at the command prompt:

perldoc -v $?

Depending on your shell, you may need to escape the $.

perldoc -h

Upvotes: 5

James McLeod
James McLeod

Reputation: 2406

This is the status returned by the last system operation, pipe, or backtick operation. See reference perlvar.

Upvotes: 14

Rob Raisch
Rob Raisch

Reputation: 17357

$? or $CHILD_ERROR (if use English) contains the status of the last backtic (or several means of running a child process from Perl.) See perlvar for a full explanation.

Upvotes: 4

Karl Knechtel
Karl Knechtel

Reputation: 61508

$?, along with all the other "magic" variables, is documented in the perlvar section of the Perl manpages. If you don't actually have a Unix-like setup with the man command, you should also be able to Google for man perlvar.

Upvotes: 9

Related Questions