Title: C++ with perl
Description: possible and how
zlice0 - March 19, 2004 02:16 AM (GMT)
I read something that said you could have a program with perl and C++, is that possible? and if it is where can i find out how to do that?
TheHawgMaster - March 19, 2004 02:34 AM (GMT)
What do you mean? I guess in the sense that most perl interpreters are probably written in C++...
btw nice to see you back around zl0 :)
Degman - March 19, 2004 03:55 AM (GMT)
I think he means both syntax..?
Perl is quite a lot different than C++, it's interpreted for one thing ;)
You can use both on a webserver, however. You could also write a file with commands for the other one, then execute it/compiler for it. I don't see any practical purpose of this, however.
kimastergeorge - March 19, 2004 04:06 AM (GMT)
Do you mean have a perl program with headers libraries from C++? Or have perl in C++ applications? Or a perl-to-C++ porter? Or C++-to-perl? :)
TheHawgMaster - March 19, 2004 05:15 AM (GMT)
No, you can have separate C++ applications (compiled) and Perl code files (interpreted), and have each launch the other. Like he said though I can't see any practical reason to do this except if you really can't find the scripts and/or CGI modules that do what you want and have to mix the two. You can't just mix C++ source and Perl together and have it work.
myork - March 19, 2004 12:57 PM (GMT)
You can call compiled C routines directly from perl. To access C++ objects you may need to use a C wrapper as the namemangling of C++ functions is not stadardised.
zlice0 - March 19, 2004 11:33 PM (GMT)
hawg thanks, i kinda got grounded for a while so that's why i wasn't around. but anyway lets say i wanted to link these 2 together.
| CODE |
C++----------------------- #include header int main() { gets(); ... }
PERL--------------------- #simple socket(); listen(); ...
|
if i wanted to add the gets() into perl, or the socket, listen into C++, how would i do that? if it's possible.
myork - March 20, 2004 04:02 AM (GMT)
Calling C functions from Perl (or perl from C/C++) are both non trivial subjects.
I have not done this personaly, but I believe that you can use the Perl xsub interface. Check out chapter 21 of "Programming Perl" by Wall, Christiansen, and Orwant. Also use google, you will quickly find lots of discussions about it and with a bit of luck some more solid advice than I can give.
If you are interested in calling Perl functions from C/C++ then you probably need to check out
SWIG.
| QUOTE |
| Perl code files (interpreted) |
Perl is actually compiled before execution. You can actually compile your perl source into the executable format and then throw away the source. NB The compiled code (like Java) is not specific to any perticular hardware thus it is this compiled physudo code that is interpreted by the 'perl Interpretor'. Thats why the Apache perl module is so fast (It only compiles each cgi script once, therafter executing the compiled code).
zlice0 - March 20, 2004 05:09 PM (GMT)
hmm <_< i get it, just need to see that chapter, thanks. i'll try to find more online, just been a pain in the butt trying to find it because google sucks when i WANT to find something.
zlice0 - March 20, 2004 05:17 PM (GMT)
hmmm, i figure this would just be better if anyone can answer this, i know it's off topic but w/e. is there anything for Windows(9x and above) that is a *nix shell? like the whole chom, cwd, bash thing? just the *nix command prompt for windows.
KTC - March 21, 2004 02:29 AM (GMT)
http://www.cygwin.com/
Oh yeah, don't bother trying to download all of cygwin if you've only got dial up ;)
Found something you might be interested in. With ActivePerl for Win32, the doc
perlembed contains exactly what you were looking for (in C alas, just do a wrapper for C++). I'm not entirely sure but suspect this doc file might come with other perl implementation as well...