How can I monkey-patch an instance method in Perl?

前端 未结 8 2291
醉酒成梦
醉酒成梦 2020-12-08 01:25

I\'m trying to monkey-patch (duck-punch :-) a LWP::UserAgent instance, like so:

sub _user_agent_get_basic_credentials_patch {
  return ($usernam         


        
8条回答
  •  时光取名叫无心
    2020-12-08 01:34

    Perl thinks you're trying to call the subroutine on the left of the assignment, which is why it's complaining. I think you may be able to whack the Perl symbol table directly (using *LWP::UserAgent::get_basic_credentials or something), but I lack the Perl-fu to correctly make that incantation.

提交回复
热议问题