moderated >> (how) can I use Perl as an inline scripting language in self written C Programs ?

by Mai Kee » Fri, 05 Aug 2005 00:52:57 GMT

Hello,

I had heard somewhere, that there is an opportunity to link an perl
interpreter together with own C-Code. Is this right?

My idea is to stip down an inbetween very complex software with very
complex and non - linear configuration and a couple of proprietary
pseudo scripting configuration files. All initialisation and actions
shall now call predefined Perl scripts. So every end user could modify
the scripts to get an modified behavior.

But to be able to do this, I have not only to share some variables
(strings and integers) with the Perl code but also functions. At least
the Perl script must be able to call some prepared C-functions and
should be able to get the return values.
As far as I understand, I cannot do this by calling perl.exe from
inside my program. because the internal function in my Program
couldn't be called by perl.

Can this be done? Which Perl "product" I have to use? Is there a good
source for informations / howtos / best current practices?

thanks for every hint onto more information.

Mai Kee

Mai Kee

--
Hamster beisst sich durch ...

moderated >> (how) can I use Perl as an inline scripting language in self written C Programs ?

by Sherm Pendley » Fri, 05 Aug 2005 01:30:17 GMT


Mai Kee < XXXX@XXXXX.COM > writes:


Yes - for starters have a look at:

perldoc perlembed

sherm--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org

moderated >> (how) can I use Perl as an inline scripting language in self written C Programs ?

by yf110 » Fri, 05 Aug 2005 03:01:42 GMT


: Hello,

: I had heard somewhere, that there is an opportunity to link an perl
: interpreter together with own C-Code. Is this right?

: My idea is to stip down an inbetween very complex software with very
: complex and non - linear configuration and a couple of proprietary
: pseudo scripting configuration files. All initialisation and actions
: shall now call predefined Perl scripts. So every end user could modify
: the scripts to get an modified behavior.

: But to be able to do this, I have not only to share some variables
: (strings and integers) with the Perl code but also functions. At least
: the Perl script must be able to call some prepared C-functions and
: should be able to get the return values.
: As far as I understand, I cannot do this by calling perl.exe from
: inside my program. because the internal function in my Program
: couldn't be called by perl.

: Can this be done? Which Perl "product" I have to use? Is there a good
: source for informations / howtos / best current practices?

: thanks for every hint onto more information.


If you have perl installed, then from the command line type

perldoc perlembed


if you don't have perl installed, then I assume google and/or www.cpan.org
will help find it to read.


You can also just shell out to perl, and then leave the results of a Perl
script in a temporary file in a format of your choosing that your C
program can most easily parse (or even just use the exit code for boolean
tests etc.). That's very easy to get started with.




This space not for rent.

moderated >> (how) can I use Perl as an inline scripting language in self written C Programs ?

by James » Fri, 05 Aug 2005 04:16:56 GMT

Your first port of call should be to read "perldoc perlembed" which
tells you most of what you need to know.

This is likely to be more complicated on windows I would imagine
(guessing from the .exe, but perl compiles under MS Visual Studio IIRC)

Cheers

James

moderated >> (how) can I use Perl as an inline scripting language in self written C Programs ?

by John Bokma » Fri, 05 Aug 2005 11:01:52 GMT


The latter can be done creating a "Perl" module which uses C code for its
implementation.

--
John MexIT: http://johnbokma.com/mexit/
personal page: http://johnbokma.com/
Experienced programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html

moderated >> (how) can I use Perl as an inline scripting language in self written C Programs ?

by Marcin Kasperski » Fri, 05 Aug 2005 18:40:36 GMT

> My idea is to stip down an inbetween very complex software with very

So ... a few remarks from my experience

a) By far best information about perl internals necessary to embed and
extend perl I found in the book 'Advanced Perl Programming'
(O'Reilly, by Srinivasan), where a few chapters describe all those
guts and macros far better than perlembed and perlxs PODs.

b) Those api's are very clumsy (ugh, embedding python is FAAAAR easier).

c) I remember that there were one or two CPAN modules related to perl
embedding and making the task easier. One of them was written by
Ken Fox, don't remember module name now, it gave some nice C++
classess to represent perl objects within C++ program.

d) And of course there is swig which make it easier to extend perl,
although is sometimes inefficient.

moderated >> (how) can I use Perl as an inline scripting language in self written C Programs ?

by Sebastien Nadeau » Fri, 05 Aug 2005 22:20:14 GMT

Hi,

I don't know if it's a good idea, but I suggested him to use SOAP to
share classes and objects between C and Perl. There's an interesting
toolkit at http://www.cs.fsu.edu/ ~engelen/soap.html to make a SOAP
server in C/C++, you could then use SOAP::Lite in Perl to call
objects methods written in C/C++.

Sastien

Sastien Nadeau
Technicien en informatique
Bibliothue de l'Universit?Laval
(418) 656-2131 ext. 6815
Notice of Confidentiality
< http://www.rec.ulaval.ca/lce/securite/confidentialite.htm> ;

Similar Threads

1. perl self generating program - Perl

2. Perl - Read and Write Multi-Language text (Scandanavian,German)

Deal all,

INFO> uname -a => Linux perlsrv 2.4.27 #1 Tue Sep 23 15:34:56 CEST
2008 i686 GNU/Linux
INFO> perl -v => This is perl, v5.8.4 built for i386-linux-thread-
multi

I  am seeking advice on  how to  generate multi-language output in
Perl.

The task here is to generate a single page of HTML, PDF and  plain
text files with each run of the Perl script.
Each of the above has to be in the language  chosen by the user in a
web-interface.
The possible choices are : Danish, Finnish , Swedish
Based on the language, I would like to read  text from a file
containing language specific characters (like AE and umlaut ) and
generate PDF,HTML and plain text output.



My questions are:
- How do I know if my OS supports printing of these languages
- How I can type in text in a editor like  vi with Finnish/Danish/Swed
characters
- How do I enable Perl to understand that a file contains language
specific characters.
- And finally what should I do to ensure that the output produced by
Perl : PDF, HTML  and plain text files dont mess up the  special
characters


Any advice on this is much appreciated. I know I can do  the file read/
write operations and output generation parts with Perl with some
effort but the language part seems quite  a challenge.

I am in a situation where I do not know where to  start.









3. Error in Perl Inline::C program running

4. Feasibility of using Perl to strip selected html tags and/or attributes (scripting/programming novice)

5. Perl and other programming language

6. Easier web programming language: PERL or PHP?

Hi all!

I would to study a web programming language to create a script that, given
the following
input page (input.htm) where the user select the weight and volume of a
package to be shipped, returns the prices of various couriers ("yellow",
"blue" and "black").
Is Perl my best choice? or PHP? ASP is much more complicated?

~~~ input page input.htm:

<form method="GET" action="output.php" name="input">

SELECT THE VOLUME OF YOUR PACKAGE:

<input type="radio" name="volume" value="1"> from 0 to 1 m3
<input type="radio" name="volume" value="2"> from 1 to 2 m3
<input type="radio" name="volume" value="3"> from 2 to 3 m3

<br>SELECT THE WEIGHT OF YOUR PACKAGE:

<input type="radio" name="weight" value="100"> from 0 to 100 Kg
<input type="radio" name="weight" value="200"> from 100 to 200 Kg
<input type="radio" name="weight" value="300"> from 200 to 300 Kg

</form>

~~~ istructions to be integrated in the "output.php" script:

Courier "yellow" - for volume 1, 2 and 3:
  if weight=100 then rate=600
  if weight=200 then rate=900
  if weight=300 then rate=1200

Courier "blue" - for volume 1 and 2:
  if weight=100 then rate=400
  if weight=200 then rate=700

Courier "black" - for volume 2 and 3:
  if weight=100 then rate=800
  if weight=200 then rate=1100
  if weight=300 then rate=1500


~~~ sample request and result:

Example A) With the user input:
volume=2
weight=300

output.php must generate this result:
courier "yellow" = 1200
courier "black" = 1500


Example B) With the user input:
volume=1
weight=100

output.php must generate this result:
courier "yellow" = 600
courier "blue" = 400



7. Mixed language programming: C++, C# and Perl - Visual Studio

8. Can I use perl ,write programs in perl without installing it on any computer

Hi ,
Can I use perl ,write programs in perl without installing it on any
computer?
IS there any perl online development simulator exists?

Thanks,
Vijayshree