return code

DBSMITH_at_OhioHealth.com
Date: 02/27/05


To: beginners@perl.org
Date: Sun, 27 Feb 2005 17:12:48 -0500

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

thank you,

#!/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);

Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams



Relevant Pages

  • Re: Newbie "undefined value"
    ... > used strict and -w. ... From that same command line, if I pass in parameters, ... > to print to a file and using parts of Stein's guestbook script. ... > sub write_datafile { ...
    (comp.lang.perl.misc)
  • Re: reading command line arguments
    ... The code already has parts the read command line arguments, ... If you use strict, as you should, then you'll need to declare $t and $e ... use warnings; ...
    (comp.lang.perl.misc)
  • Newbie "undefined value"
    ... From that same command line, if I pass in parameters, ... I thought "strict" would catch all ... I had a short script that printed to the browser. ... sub write_datafile { ...
    (comp.lang.perl.misc)
  • Re: beginner trying to use Getopt::Long
    ... run the program with various values at the command line (actually they ... use strict; ... die " program requires startdate argument \n"; ...
    (comp.lang.perl.misc)
  • RE: More Info About $| = 1;
    ... Might it have something to do with Eclipse? ... use strict; ... use warnings; ... the command line does nothing until I enter some text, ...
    (perl.beginners)