How to tie every variable in perl script?

后端 未结 1 688
轻奢々
轻奢々 2021-01-18 17:56

I want to see every place when variable in perl script is created/accessed/destroyed

It is easily reachable using tie or Variable::Magic

But how

相关标签:
1条回答
  • 2021-01-18 18:25

    You can take a look at B::Xref which generates a cross reference listing of all variables in your application. Basically, you need to walk the byte code to find all variable declarations/initializations. You can also alter the byte code, i.e. add code to tie the variables. However, I cannot point you to an example, because this is rarely done.

    As an alternative, you could use a code filter to add the tie() instructions. However, code filters are not guaranteed to correctly identify variable declarations/initializations.

    0 讨论(0)
提交回复
热议问题