|Don't ask to ask, just ask|
Possible issue with Moose ScalarRefby greengaroo (Hermit)
|on Jan 10, 2013 at 17:54 UTC||Need Help??|
greengaroo has asked for the
wisdom of the Perl Monks concerning the following question:
Happy new year fellow Monks!
I am either doing something wrong or I just found a bug in Moose. I hope its me and not Moose!
What I am trying to do is to save a reference to a scalar in another object so if I change the value of the original scalar in my first object, it will be effective also in the second object.
About this syntax, keep in mind I am using MooseX::Declare, also in this case the "debug_level" in $self isa Int and the "debug_level" in the $obj (Something class) it isa ScalarRef[Int]. My code roughly look like this:
And the output is:
Why is the SCALAR address not the same? And of course, that leads to the problem of the second instance not being updated!
Here is the definition of the attribute in the first class (it extends MooseX::App::Cmd::Command):
Here is the definition of the attribute in the second class (it uses MooseX::Declare):
What am I doing wrong??? Thank you all!
UPDATE: I found a workaround, and it seems to do what I want, but I still have a different SCALAR address for the original and the reference. I now do this: