Is there a way to create perl source code, if I have the opcode?
For example
perl -MO=Concise -e "print 123"
will output the opcode:
6 <@> leave[1 ref] vKP/REFC ->(end)
1 <0> enter ->2
2 <;> nextstate(main 1 -e:1) v:{ ->3
5 <@> print vK ->6
3 <0> pushmark s ->4
4 <$> const[IV 123] s ->5
I would like to reverse this somehow.
While B::Concise tries to give an accurate representation of the opcode tree, B::Deparse takes the opcode tree and produces source code from it.
$ perl -MO=Deparse -e'$x && print'
print $_ if $x;
-e syntax OK
It's quite good, though there are some limitations.
Given that B::Concise tries to be very complete, it might be possible, but I think some information is missing. I'm pretty sure there's nothing that tries to do this on CPAN, since I've never heard of blead breaking it (something you would expect to happen regularly).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With