Listing 3
void eperl::CPerlInterpreter::Eval(const std::string perlCode)
{
PERL_SET_CONTEXT(reinterpret_cast<PerlInterpreter*>(m_perl));
sv_setpv(ERRSV, reinterpret_cast<const char*>(&PL_sv_undef));
// Evaluate the perl code and return a string
perl_eval_pv(perlCode.c_str(), G_KEEPERR);
if (SvTRUE(ERRSV))
{
std::string errorSv = SvPV(ERRSV, PL_na);
std::string error =
"eperl::CPerlInterpreter::Eval() failed: " + errorSv;
throw CInterpreterException("Failed to evaluate
the Perl command string", __FILE__, __LINE__, error);
}
}