Run code on object creation after new() and bless?
[email protected] (Tod Hagan)
| Newsgroups | perl.moose |
|---|---|
| Message-ID | <[email protected]> |
Hi all, I've got a container object with a hashref of other objects. Given one of the contained objects, the code is going to need to be able to get a reference to the container without a brute force search of all containers. The hashref is 'ro' and passed to new as the data structure is fixed and not subject to change after creation. One way to create the backreferences is with a method to be called after new returns, but this is subject to bugs if the method call is omitted after creating a container. This ends up looking much like a dynamic container which starts empty to which items are added via an add method. I tried creating a base class and extending it using a method modifier on 'new', but the problem is that it gets control before the object has been blessed and thus there's no reference. Is there a way to run code following object creation and the blessing of the object? Or should I give up trying to hide the extra method call and require calling a method following the creation of the object? Thanks. Tod -- Tod Hagan Information Technologist AIRMAP/Climate Change Research Center Institute for the Study of Earth, Oceans, and Space University of New Hampshire Durham, NH 03824 Phone: 603-862-3116