Thread Perlembed: Perl und C: Arrays (1 answers)
Opened by Gast at 2007-05-14 17:48

Gast Gast
 2007-05-14 17:48
#76707 #76707
hallöschen!
ich habe da eine frage über Perlembed, nachdem ich perlembed doc gelesen habe: Über der Perl Intepreter soll ein code in C lesen:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#Mytest.pl
sub Mypace {
use vars;
@area = (flur, door,küche,zimmer,balkon);
return @area;
}

/// Mytest.c

#include <EXTERN.h>
#include <perl.h>
#include <stdio.h>
#include <string.h>

static PerlInterpreter *my_perl;

static AV*runit()
{
 dSP;
 char *reserved;
 SV *result;
 ENTER;
 SAVETMPS;
 PUSHMARK(SP);
     PUTBACK;
     perl_call_pv("Myplave", G_ARRAY);
     SPAGAIN;
    result = POPs;
     reversed = SvPV(result,PL_na);
       PUTBACK;
   FREETMPS;
 LEAVE;
}


main()
{

      int argc;
      AV* test;
      char **argv;
      char **env;
      char *embedding[] = { "", "-e","0"};
char *my_argv[] = {"","Mytest.pl"};
     my_perl = perl_alloc();
     PERL_SYS_INIT3(&argc, &argv,&env);
     perl_construct(my_perl);
     perl_parse(my_perl, NULL,2, my_argv,NULL);
     PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
     perl_run(my_perl);
    test =  runit()
         perl_destruct(my_perl);
         perl_free(my_perl);  
         PERL_SYS_TERM();
   }

ich will lediglich dass "Mytest.c" der von "Mytest.pl" wiedergegeben Array liest.
Mit diesem Code funktionniert es nicht! Ich weiss nicht, wo es hackt. kann jemanden mir helfen, es zu verbessern?

danke

View full thread Perlembed: Perl und C: Arrays