develooper Front page | perl.perl5.porters | Postings from July 2017

eval_pv package

Thread Next
David Mertens
July 6, 2017 13:06
eval_pv package
Message ID:
Hello all,

perlapi mentions that eval_pv can evaluate a block of Perl code. It does
not indicate the package in which the evaluation occurs. In C::Blocks, I
use this to allow for generation of C code with a Perl block. It appears
that eval_pv is run in the "main" package. This is certainly the case when
used during the operation of a hooked keyword.

I would really like for the package to be that in which the keyword is
actively parsing. It's easy enough to achieve that by prepending the eval'd
C string with a package statement (and a #line statement, while I'm at it),
but I wanted to know if there was any more direct way of telling eval_pv
about the package in which it is being evaluated.


 "Debugging is twice as hard as writing the code in the first place.
  Therefore, if you write the code as cleverly as possible, you are,
  by definition, not smart enough to debug it." -- Brian Kernighan

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About