Front page | perl.perl5.porters |
Postings from July 2017
From: David Mertens
July 6, 2017 13:06
Message ID: CA+4ieYV1Dk7Xsh7+amV2B0a6m40t6L3NW7r+QFKRx9=xKkDrbQ@mail.gmail.com
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
by David Mertens