Jul 14, 2014, 5:56 AM
Post #1 of 5
Perl 5.8.8 on Linux RHEL 5.5.56.
How to pass string msg from b.pl called from control.pl
I don't think the use of modules is a good idea since I know nothing of writing modules, in fact I'm just learning to use modules and hash refs and array refs. I do not have time to learn modules, but perhaps later.
I'm trying to keep this simple. Not using modules, and using separate .pl files, is a good solution for us at this time.
I have a Perl program, control.pl, which reads an email, and based on that email, determines which other Perl script to call, like b.pl. Control.pl also opens its own log/error file. So if program b.pl gets called, and has an error, I want to pass an error string back to control.pl, so I can log it to the same log file control.pl is using. This will help centralize error messages to one file.
Can exit do that? If not, how can I do this?
I know exit returns a numeric code, sometimes negative, so if that's all I can do, it's acceptable. But surely people can understand my want for a more useful string error message.
I'm doing it this way to make it modular, because in the future we expect to use the same email account to process a variety of files. Each different file will need a different script to process.
For now we will be using the same email address to process 2 types of files, and calling 2 Perl scripts.
Also, this is how control.pl is calling the script:
$script='$HOME/'.$mprintreqdir."/conv.pl address.dat $msgnum ";
# Exit status in $?.
$err=`$script`; # Capture output to $err.
Is that correct for calling another program, returning to the original program, and capturing any string messages?
$mprintreqdir can vary based on if I'm in the production or testing directory, both of which are on the same server. This does not use a database so there is no need to have a different server, or different database for testing and production. I will deal with the changing of $mprintreqdir later, but if you have ideas, like a field of corn, I'm all ears.
(This post was edited by bulrush on Jul 14, 2014, 6:22 AM)