Pass variables around the around method modifier

前端 未结 2 403
你的背包
你的背包 2021-01-24 11:37

Is it possible to pass variables between multiple calls to the around MethodModier? example (that doesn\'t work but hopefully conveys what I want to do)

<         


        
相关标签:
2条回答
  • 2021-01-24 12:00

    Use an instance variable:

    $self->{value} = get_value;
    ...
    my $value = $self->{value};
    

    (See question commments for an actual answer. I'm just reiterating it here, so I can accept an answer, thanks to:

    )

    0 讨论(0)
  • 2021-01-24 12:17

    What you are trying to do don't have logic.

    "An around modifier receives the original method as its first argument, then the object, and finally any arguments passed to the method."

    https://metacpan.org/pod/Moose::Manual::MethodModifiers#BEFORE-AFTER-AND-AROUND

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