As I mentioned before, all programs provide the shell with an exit status. No errors is indicated by 0. The simple thing is to make a batch file and stop executing Perl programs when you get a non zero status code (no matter if negative or positive).

You don't mention your OS. For Windows command line:
test.bat

ECHO test.bat file starting.... perltest1.pl IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL% perltest2.pl
perltest1.pl
use strict; use warnings; open my $fh, "<", "bogus file" or die "unable to open file $!";
perltest2.pl
use strict; use warnings; print "this is test2";
running test.bat yields:
C:....PerlProjects>perltest1.pl unable to open file No such file or directory at C:......\PerlProject +s\perltest1.pl line 4. C:....PerlProjects>IF 2 NEQ 0 EXIT /B 2
So testperl1.pl returns code of 2. testperl2.pl never runs.

There are all sorts of fancy things that can be done with shell scripts. My advice is to keep things simple. Just automate the running of separate commands for each Perl program. Don't use Perl to run Perl programs. And avoid other tricky module oriented syntax. If you have a bash shell on Unix, then there is an equivalent set of statements which will do the same thing.

Update:
Now if you want to cause a non-zero exit, then "exit(2345);" in your Perl program will return code 2345.

Since you are using an Oracle DB, I would just use one of the many INI modules on CPAN to read an INI file with account and password. You will have a small amount of "boiler plate" code to add to each of your programs, but I don't see a problem with that.

And I guess you could pass the account and password to each of the programs from the command line. But overall, I think using an INI module is the least complicated way to do what you want.


In reply to Re^4: designing a program - your wisdom needed by Marshall
in thread designing a program - your wisdom needed by SpaceCowboy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.