According to the Perl Programming book, the $? is the status word returned by the 
wait(2) system call so the exit
value of the subprocess is actually ($? >> 8). The >> operator is a binary shift 
right, where the left argument is
shifted right the number of bits of the right argument.

Hope this helps.
randy

-----Original Message-----
From: Nick Drage [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 12, 2003 3:08 PM
To: [EMAIL PROTECTED]
Subject: Re: $?


On Thu, Jun 12, 2003 at 08:05:48PM +0200, Olivier Wirz wrote:
> Hello,
> 
> I would like to know if there is a way to check $? to see whether the 
> programm ran correctly in such a statement:
> 
> @results =`grep $search $_`;
$exitcode=$?;

And there you have it, $exitcode is your exit code.

I was given this answer by David van der Geer, who used:

$exit_value = $? >> 8;

I'm not sure what " >> 8 " means though, anyone?

Also when I asked this Steve Grazzini advised:

<quote>
Nick Drage <[EMAIL PROTECTED]> wrote:
>                                                                                      
>    
> How do I capture the output and the exit code of a process?                          
>    
> Basically I'm looking to combine the functionality of backticks                      
>    
> and the system call.                                                                 
>    

Use backticks; and the wait() status that system returns
will be in $?.
</quote>

-- 
 
?


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to