Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!dimacs.rutgers.edu!rutgers!carssdf!usenet From: usenet@carssdf.UUCP (John Watson) Newsgroups: comp.lang.perl Subject: Re: calling perl from C Message-ID: <302@carssdf.UUCP> Date: 26 Apr 91 13:22:19 GMT References: <1991Apr25.172948.655@cis.ohio-state.edu> Organization: C.A.R.S.,Middlesex,NJ Lines: 28 In article <1991Apr25.172948.655@cis.ohio-state.edu>, george@cis.ohio-state.edu (George M. Jones) writes: > I thought I would check with people here to see if anyone has already > come up with some way of calling perl routines from C. I'd even welcome... I have written a usersub.c for perl to access Faircom Ctree data base and Dtree screen routines. With in the Dtree screens, they need to be able to handle exceptions/hooks by calling perl routines or by executing perl expressions. I do this by calling do_eval as follows. src = Str_new(99,40); /* make a place for the userfunc */ str_set(src,parms); str = Str_new(99,0); interp(str,src,usub_sv_sp); str_free(src); rtn_cnt = do_eval(str,O_EVAL,curstash,G_SCALAR,usub_sv_sp); st = stack->ary_array + rtn_cnt; str_free(str); cp = (char *)str_get(stab_val(stabent("@",TRUE))); if (*cp) { fatal ("Error in HOOK <%s>\n %s ",parms,cp); } If you would like the whole source to wade through (1500 lines) just let me know. John Watson (self employed)