http://qs1969.pair.com?node_id=517464


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

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.

Replies are listed 'Best First'.
Re^4: Doubts of a perl beginner on PERLEMBED
by jithoosin (Scribe) on Dec 17, 2005 at 11:40 UTC
    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...