wrote:
> Hi Everybody,
>
> I am a new-bee in PERL.
Then you would do well to read some of the FAQs with come with Perl.
Starting with
perldoc -q difference
"What is the difference between 'Perl' and 'perl'?"
> Basically, I am a VC++ programmer. I am in the
> process of running PERL script from my VC++ code. I have completed this
> task succcessfully. Now, I am facing a problem. As I am running my perl
> script from my executable, I am unable to get any of the messages
> displayed by perl compiler, like compiler errors, print outputs etc. To
> be specific, any messages to stdout and stderr.
>
> Is there a way to capture those messages? Can anybody help me?
If I understand correctly what you're asking, I don't believe this
question has anything to do with Perl. It has to do with whatever
language the parent program is written in, which you say is C++. You
can tell it has nothing to do with Perl because the question would be
the same no matter what language the child program is written in.
What you need to do is figure out how to capture STDOUT and STDERR by
whatever method your C++ executable is calling a child process. For
that, I would suggest asking one of the C++ newsgroups, instead of the
Perl newsgroup.
If, on the other hand, you are attempting to redirect the Perl
program's STDOUT and STDERR from within the Perl program itself, you
can do it like so:
open STDOUT, '>>', 'outfile.txt' or die "Can't redirect STDOUT: $!";
open STDERR, '>>', 'errfile.txt' or die "Can't redirect STDERR: $!";
>From that point on, all prints and warnings that the Perl script (but
not the perl interpreter that runs your Perl script!) generates will be
directed to the files outfile.txt and errfile.txt, respectivly.
Paul Lalli