status of perl script in another ...

Hi,

Is there a way to get the status of a perl program in another perl script ?

Ex.:
1/ proc_sub.pl:
print "test programme perl\n" and exit 1;

2/ proc_main.pl:
print "status of proc_sub.pl : ";
proc_sub.pl # possibility to get the status=1 ???

Thanks a lot.

Yes. require() proc_sub.pl in proc_main.pl and the return value is what you need. The return value can be anything, except 0. Of course, in proc_sub.pl you shouldn't use exit then, or the proc_main.pl will also be terminated. You can use return instead.

Thanks but do you know if there is a syntax calling proc_sub with arguments:

require proc_sub "arg1" "arg2" ... "argn" # ?

require() doesn't work that way. Basically it only loads the file, executes it and return the return value. Actually, from your description I think you mean to put it in another way. For example:

a.pl: ====================

require "b.pl";

$retval = &some_sub(arg1, arg2, ...);
# get 5

b.pl: =====================

sub some_sub {
#...
return 5;
}

1;

If in doubt, please read the perlfunc manpage for description on require().

ok. I think i've no choice.

Thanks.