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


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

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.

Replies are listed 'Best First'.
Re^5: Doubts of a perl beginner on PERLEMBED
by robin (Chaplain) on Dec 17, 2005 at 15:25 UTC
    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...