Hi,
I have an embedded PERL script which is parsed and run from a C++ app on
Win32 platform. The C++ app is MFC based without any console!

>>Related code snippet is:
static PerlInterpreter *my_perl;
my_perl = perl_alloc();
perl_construct(my_perl);
perl_parse(my_perl,xs_init,argc,argv,_environ);
perl_run(my_perl);
..
..
perl_destruct(my_perl);
perl_free(my_perl);

##########perl script:
##########test.pl
use my_test.pm
print "inside test.pl script";

Apparently there does not exist any my_test.pm file; if I run this .pl file
via commandline with perl.exe I get the following error message:
>>syntax error at tmp.pl line 1, near "use my_test."
>>Execution of tmp.pl aborted due to compilation errors.

My aim is to get the same error message while running the perl script via
the embedded C++ application. My understanding is that the error message
gets re-directed to "stderr", so I tried closing stderr and reopening with a
new file handle, but that doesn't seem to work; no messages get routed to
the "new" stderr!! Apparently the "stderr" has been over-riden by the PERL
IO layer, and I can't find a way to reset that...

Another issue I encountered was that in my C++ code, if I include <perl.h>,
any attempt to open a file crashes!!!! 
i.e.
#include <iostream.h>
#include <perl.h>
void main()
{
 FILE* fp = NULL;
 fp = fopen("C:\\test.txt", "a+");
 ....
}
crashes while executing fopen! To overcome this I had to include
WIN32IO_IS_STDIO in the preprocessor definition. 
None of these problem occurs with hp-ux though - closing stderr and
re-directing std error values to a new file pointer works perfectly fine!!
So does any other file IO activities!!

I was wondering if I am missing out something basic in the PERL IO layer; I
went through the PERL source code, but couldn't make out much from there :((
I would deeply appreciate if anybody in the list could share their thoughts
on this problem.

Thanks,
Gopa

Reply via email to