Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Perl on Windows - use Perl as DLL

Reply
Thread Tools

Perl on Windows - use Perl as DLL

 
 
Snorik
Guest
Posts: n/a
 
      08-28-2009
Hello everyone,

is it possible to use the perl interpreter as DLL to pass arguments
(scriptname, arguments and so on) in the windows way of loadLibrary(),
sendMessage:lparam:wparam: closeLibrary()?

I am normally using perl on Solaris, or just as scripting language,
but now I would like to embed perl in some other language...
 
Reply With Quote
 
 
 
 
claus.kick@googlemail.com
Guest
Posts: n/a
 
      08-29-2009
On 28 Aug., 16:46, Daniel Molina Wegener <(E-Mail Removed)> wrote:

> Look at the perlembed manual page.
>
> http://www.perl.com/doc/manual/html/pod/perlembed.html


Hello,

ok, thanks for that, but I think that is not quite what I am looking
for.

This:

http://docs.activestate.com/activepe...ws/PerlEz.html

is I think what I need.

I had been wondering whether there were better ways than doing (sorry
for the Java)

Runtime.getRuntime().exec(new String[] {"perl.exe", "script.pl",
"arg1", "arg2"});

 
Reply With Quote
 
 
 
 
claus.kick@googlemail.com
Guest
Posts: n/a
 
      08-29-2009
On 29 Aug., 13:13, "(E-Mail Removed)"
<(E-Mail Removed)> wrote:
> On 28 Aug., 16:46, Daniel Molina Wegener <(E-Mail Removed)> wrote:
>
> > Look at the perlembed manual page.

>
> > http://www.perl.com/doc/manual/html/pod/perlembed.html

>
> Hello,
>
> ok, thanks for that, but I think that is not quite what I am looking
> for.
>
> This:
>
> http://docs.activestate.com/activepe...Windows/PerlEz....
>
> is I think what I need.
>
> I had been wondering whether there were better ways than doing (sorry
> for the Java)
>
> Runtime.getRuntime().exec(new String[] {"perl.exe", "script.pl",
> "arg1", "arg2"});


Ok progress:

I can load the library, create an interpreter, but calling PerlEzCall1
(...) fails with: 5 -> Function call caused an exception
I figure my error is not knowing what to pass as pFunction - pointer
name of the function to call.

What do I have to pass as function parameter?
 
Reply With Quote
 
claus.kick@googlemail.com
Guest
Posts: n/a
 
      08-29-2009
On 29 Aug., 16:12, Christian Winter <(E-Mail Removed)> wrote:
> (E-Mail Removed) schrieb:
>
>
>
> >>http://docs.activestate.com/activepe...Windows/PerlEz....

>
> >> is I think what I need.

>
> >> I had been wondering whether there were better ways than doing (sorry
> >> for the Java)

>
> >> Runtime.getRuntime().exec(new String[] {"perl.exe", "script.pl",
> >> "arg1", "arg2"});

>
> > Ok progress:

>
> > I can load the library, create an interpreter, but calling PerlEzCall1
> > (...) fails with: 5 -> Function call caused an exception
> > I figure my error is not knowing what to pass as pFunction - pointer
> > name of the function to call.

>
> > What do I have to pass as function parameter?

>
> The name of the function. If you're just trying to run a script,
> you don't have to invoke PerlEzCall at all, the script will be
> executed when you call PerlEzCreate. What you won't have is
> a capturing facility for STDOUT and STDERR, so in case you need
> that, invoking a command line perl or linking the interpreter
> directly as in perlembed might be more convenient in the long run.
> PerlEzCall is used to invoke a specific function, seehttp://www.perlmonks.org/?node_id=571371
> for an example.


I am sorry to ask in such a stupid way, but do you mean "sub routine"
with "function"?

Wouldnt it be possible to basically create a main() sub routine in a
script like this:

#!c:\perl\bin

my $name = $ARGV[0];

main();

sub main
{
print "hello world: ".$name."!\n";
}


and hence be able to have STDOUT and STDERR (thats probably what
lpBuffer is for)?


 
Reply With Quote
 
claus.kick@googlemail.com
Guest
Posts: n/a
 
      08-29-2009
On 29 Aug., 17:18, Christian Winter <(E-Mail Removed)> wrote:
> (E-Mail Removed) wrote:
> > On 29 Aug., 16:12, Christian Winter <(E-Mail Removed)> wrote:
> >> (E-Mail Removed) schrieb:
> >>>>http://docs.activestate.com/activepe...Windows/PerlEz....
> >>>> is I think what I need.
> >>>> I had been wondering whether there were better ways than doing (sorry
> >>>> for the Java)
> >>>> Runtime.getRuntime().exec(new String[] {"perl.exe", "script.pl",
> >>>> "arg1", "arg2"});
> >>> Ok progress:
> >>> I can load the library, create an interpreter, but calling PerlEzCall1
> >>> (...) fails with: 5 -> Function call caused an exception
> >>> I figure my error is not knowing what to pass as pFunction - pointer
> >>> name of the function to call.
> >>> What do I have to pass as function parameter?
> >> The name of the function. If you're just trying to run a script,
> >> you don't have to invoke PerlEzCall at all, the script will be
> >> executed when you call PerlEzCreate. What you won't have is
> >> a capturing facility for STDOUT and STDERR, so in case you need
> >> that, invoking a command line perl or linking the interpreter
> >> directly as in perlembed might be more convenient in the long run.
> >> PerlEzCall is used to invoke a specific function, see

>
> >>http://www.perlmonks.org/?node_id=571371

>
> >> for an example.

>
> > I am sorry to ask in such a stupid way, but do you mean "sub routine"
> > with "function"?

>
> Exactly.
>
>
>
> > Wouldnt it be possible to basically create a main() sub routine in a
> > script like this:

>
> > #!c:\perl\bin

>
> > my $name = $ARGV[0];

>
> > main();

>
> > sub main
> > {
> > print "hello world: ".$name."!\n";
> > }

>
> > and hence be able to have STDOUT and STDERR (thats probably what
> > lpBuffer is for)?

>
> lpBuffer is the storage for the sub's return value, i.e. if your sub
> read:
> sub main
> {
> return "hello world";}
>
> then lpBuffer would contain the string "hello world". Anything you
> print to STD(OUT|ERR) will be invisible, unless you redirect it
> explicitely in the perl code.


OK, thanks for pointing that out.

> A downside of this kind of invokation is that the size of lpBuffer
> is defined before the invokation, so there IMHO is no (or better, no
> both easy and sensible way) to capture arbitrarily long return values,
> making it neccessary to be very thorough in defining possible return
> values for subs called this way.


I have been wondering about that.
One thing that comes to my mind is just to return a pointer (plus
size)
and have the calling language read the return value.

Or the easy solution: just return a temporary file name.

Thank you very much for your help - I still get Error 5 (Function call
caused an exception - sounds very generic) but that is just me doing
something wrong with calling the DLL.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creat a DLL File from python code, and use that DLL file in other Platform (Labview, Java .NET etc) macedo.silva@gmail.com Python 2 03-09-2007 05:52 PM
How to determine if a DLL is a COM DLL or .NET DLL Anushi ASP .Net 5 10-28-2004 01:59 PM
Why does Ruby use both tcl83.dll and tk83.dll (instead of just tk83.dll)? H. Simpson Ruby 4 08-03-2004 04:45 PM
mprapi.dll --> samlib.dll --> ntdll.dll issue. Some1 Computer Support 4 04-05-2004 02:02 AM
msvcrt.dll, msvcirt.dll, msvcrt20.dll and msvcrt40.dll, explanation please! Snoopy NZ Computing 16 08-25-2003 12:34 PM



Advertisments