How can I redefine Perl class methods?

前端 未结 5 1823
日久生厌
日久生厌 2020-12-30 08:27

The question \"How can I monkey-patch an instance method in Perl?\" got me thinking. Can I dynamically redefine Perl methods? Say I have a class like this one:



        
5条回答
  •  一向
    一向 (楼主)
    2020-12-30 08:56

    I write about several different things you might want to do in the "Dynamic Subroutines" chapter of Mastering Perl. Depending on what you are doing, you might want to wrap the subroutine, or redefine it, or subclass, or all sorts of other things.

    Perl's a dynamic language, so there is a lot of black magic that you can do. Using it wisely is the trick.

提交回复
热议问题