Return Codes in Perl: Question on implementing good patterns

M

Matt_Pettis

Hi,

I have some perl scripts that I am going to call in sucession from a
scheduling program (ESP, actually). I would like to control the flow
of executed scripts based on return codes from each of my perl scripts.

My question: does anybody have any good patterns of implementing this?
My thought is to maintain a global `$error_level' variable throughout
my script and then return its value in an END block. However, before I
go on and implement this, I'd like to hear about any
experiences/suggestions from experienced programmers on how they've
implemented this in perl.

Thanks,
Matt
 
J

John Bokma

Matt_Pettis said:
Hi,

I have some perl scripts that I am going to call in sucession from a
scheduling program (ESP, actually). I would like to control the flow
of executed scripts based on return codes from each of my perl scripts.

My question: does anybody have any good patterns of implementing this?
My thought is to maintain a global `$error_level' variable throughout
my script and then return its value in an END block. However, before I
go on and implement this, I'd like to hear about any
experiences/suggestions from experienced programmers on how they've
implemented this in perl.

perldoc -f exit
 
X

xhoster

Matt_Pettis said:
Hi,

I have some perl scripts that I am going to call in sucession from a
scheduling program (ESP, actually). I would like to control the flow
of executed scripts based on return codes from each of my perl scripts.

My question: does anybody have any good patterns of implementing this?

I would implement in Perl, not ESP. I don't know how you would do it in
ESP.
My thought is to maintain a global `$error_level' variable throughout
my script and then return its value in an END block.

By "return" a value I assume you mean exit with that as its exit status,
right? Why not just call "exit" with the right value at the point you want
to exit?
However, before I
go on and implement this, I'd like to hear about any
experiences/suggestions from experienced programmers on how they've
implemented this in perl.

I generally find that an exit status has too little information capacity
to be very flexible. I'd check the STDOUT (or STDERR), rather than (or in
addition to) the exit status of each perl script. Then you can carefully
plan your allowed error messages as strings, not just tiny integers.

Xho
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,481
Members
44,900
Latest member
Nell636132

Latest Threads

Top