Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read perl script from c++

Tags:

c++

perl

I've to read and parse HTML file and populate a data structure (in C++). I'm planning to do the parsing using perl (so I can use some other perl modules.). My requirement is this.

  1. Get the file from gui (C++ code)
  2. Pass it to perl.
  3. Parse file on perl side (perl script using some other perl modules), populate the C++ structure
  4. Continue working on C++ side with the populated structure.

I'm reading about extending and embedding perl, but unable to figure out the correct procedure. Any help would be greatly appreciated.

like image 526
Surya Avatar asked Jan 27 '26 12:01

Surya


2 Answers

In your reading did you find perlembed in Perl's documentation? That's the definitive resource for learning how to embed Perl in a C/C++ program. The author of the document was one of the original mod_perl developers, I believe.

I don't think that embedding Perl for a trivial task would be the easiest solution when compared to doing a system call to perl and parsing the result, but for more involved needs it's certainly a solution.

like image 102
DavidO Avatar answered Jan 30 '26 00:01

DavidO


I've used swig to connect C++ and Python. The documentation says it works for Perl, also.

like image 40
Robᵩ Avatar answered Jan 30 '26 02:01

Robᵩ