Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: Obtaining a return code

by chromatic (Archbishop)
on May 21, 2000 at 08:11 UTC ( #13982=note: print w/replies, xml ) Need Help??

in reply to Obtaining a return code

The special variable $? holds the status of the backtick or system operation. If you're really curious, you can do: my $sig_number = ($? & 255); to see which signal killed the process, if any. It's not all that useful, though, for system(), as you can get the return value anyway (as turnstep points out below).

Which return code are you expecting?

Replies are listed 'Best First'.
RE: Answer: Obtaining a return code
by turnstep (Parson) on May 21, 2000 at 20:36 UTC
    But $? is the same thing as just reading the return value yourself, right? At any rate, $? on my Win32 system doesn't show anything except "0", no matter what is in the system call:
    $rv = system("uname"); print "Returned a $rv and \$? is $?\n"; $rv = system("ver"); print "Returned a $rv and \$? is $?\n";

    Unix produces:

    Returned a 0 and $? is 0
    Returned a 65280 and $? is 65280

    Windoze produces:

    Bad command or file name
    Returned a 0 and $? is 0
    Windows 98 [Version 4.10.1998]
    Returned a 0 and $? is 0

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://13982]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2020-10-28 03:35 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (259 votes). Check out past polls.