[EMAIL PROTECTED] wrote:
All,
am I using the correct method to get the return code whether a previous
line or command was 0 false or 1 true?


#!/usr/local/bin/perl -w

use strict;
use strict 'subs';

my $file = qq(/tmp/mbfree);
open (F, "+<$file") or die "unable to open file $file $!\n";

foreach (<F>)  {
        if ( $. > 2 ) {
        last;
        } else { print "return code is: $? \n";
        last;
        }
}
print "line count is: $. \n";
print "return code is: $? \n";
close (F);

perldoc perlvar [snip] $? 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 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.)


Since you are not creating a child process, the $? variable does not contain any useful information.



John
--
use Perl;
program
fulfillment

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to