more useful options | |
PerlMonks |
Re: Possible issue with Moose ScalarRefby tobyink (Canon) |
on Jan 10, 2013 at 20:23 UTC ( [id://1012737]=note: print w/replies, xml ) | Need Help?? |
I agree; this seems broken. Small test case...
If you use Moo instead of Moose, then things work as expected. UPDATE: OK, not a bug. It's just that the reference \$obj1->attr is not guaranteed to be a reference to the slot within the object. So changing data via the reference will not necessarily effect $obj1. If it works, it works; if not, then it won't; no guarantees. Currently it works in Moo but not Moose, but the situation - in either - could change. If you want what you want (for both objects to have access to the same piece of data) then you need it to be a scalar ref in both classes. UPDATE 2: It also fails in Moo if Moo is in pure Perl mode (not XS).
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
In Section
Seekers of Perl Wisdom
|
|