|No such thing as a small change|
Re: Help with Class::InsideOutby Tanktalus (Canon)
|on Feb 19, 2016 at 18:41 UTC||Need Help??|
You have two basic problems here.
The first problem, the uninitialized errors, is that your new class method is not actually creating the object, or at least isn't keeping it. You're calling register, but you're discarding the registered object. I'd suggest:
Note that we're also returning $self. It's important.
The second problem is that your calls to the readonly function, and it is a function!, happens after you're done trying to print $person->given_name - in other words, Class::InsideOut doesn't know anything about these readonly attributes yet! If you were to put your package into My/Person.pm so you could use it, that would solve your problem. Or, for test purposes, move it to the top of the file so it gets executed first.
With those two changes, and an extra space after Name is just so it looks nicer, I have:
And this works fine :)