Overriding qx//
Nik Clayton
nik at ngo.org.uk
Thu Apr 13 13:21:08 BST 2006
> Whilst not something to be done if you value efficiency, you could use
> Filter::Simple and PPI. I've been writing a module that needs to do more
> than can be achieved with overloading and so have tried this out. Using
> PPI, you can inspect the parse tree for interesting constructs, and then
> rewrite them as function calls to carry out the new behaviour at
> runtime (yes, I know this is a bit icky).
Slightly more heavyweight than I'd like.
I've just spent some time noodling around with this. I've got a hunch
that I should be able to do this with a Devel:: module and B. If I do
perl -MO=Concise test.pl
I can see the backtick operators. What I'd like to do is write a debugger
that single steps through the program, checks each OP, and if it's a
backtick OP then log the necessary debug info (bonus marks if I can change
the OP value on the fly, so that it's executing something I want it to
execute).
Sadly, I haven't got much of a clue how to do that at the moment. I can
write a Devel:: module, and have DB::DB() be called for each line. That
much is relatively simple.
What I haven't figured out is how, within my DB::DB(), to get the optree
for the currently executing statement.
N
More information about the london.pm
mailing list