Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: Doubts of a perl beginner on PERLEMBED

by jithoosin (Scribe)
on Dec 17, 2005 at 09:48 UTC ( [id://517456]=note: print w/replies, xml ) Need Help??


in reply to Re: Doubts of a perl beginner on PERLEMBED
in thread Doubts of a perl beginner on PERLEMBED

Hi Robin,

Thanks for the good & useful replies. I will not be able to combine 2 perl files into one . And one of my aims is to invoke the perl interpreter only once. In your example i have seen "perl" as the first argument for "my_args". What does that signify? .Usually people put that field as empty ("") .And one more thing is that whether specifying "perl" as the first argument of "my_argv" may cause the perl intepreter to be invoked every time i call a perl subroutine.

Replies are listed 'Best First'.
Re^3: Doubts of a perl beginner on PERLEMBED
by robin (Chaplain) on Dec 17, 2005 at 11:00 UTC
    You're being rather mysterious, which makes it harder to give helpful answers. (Why can't you combine the two scripts into one? Why do you aim to invoke the Perl interpreter only once?)

    I don't think the first element of argv is used. I prefer to set it to ‘perl’ because, logically, it’s supposed to be the name that the program was invoked with. But set it to ‘fiddlesticks’ if you prefer – I don’t think it will make any difference to the result.

      Hi

      The reason for not combining 2 different files is that they are for different functionality.One for extracting html tags from a html file anc checking whether which all browser version supports them and other file is for checking the html error in they file using "TIDY". And i donot believe in combining 2 different files which provides entirely different functionalities to complicate matters.

      Actually previously these 2 files have been called by "system" command in C and "popen" was used for passing and getting arguments between C and perl.But this reduced speed of execution. So i am trying to increase the speed by embedding perl in C

      Any way THANKS for all your replies and suggestion & helping novices like me.Always keep this good mind with you.
        If you're calling the Perl code repeatedly from the C, that's a reasonable thing to do, because you need only compile it once.

        The best way to do it is probably to make sure all your Perl code is in subroutines (so running the script from the command-line) doesn't actually do anything), and that you don't have any name clashes between the two files. (Use separate packages if necessary.)

        Then load both the files in, by parsing (perl_parse) and executing (perl_run) a one-liner that requires them both, as I indicated earlier. Once you've done that, you can call your subs using one of the call_* functions described in perlcall.

        Good luck! Embedding perl is a pretty “advanced” topic for a self-described perl beginner. Good for you for not being afraid to try! But don't expect it to be particularly easy or clearly documented...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://517456]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-03-28 23:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found