in reply to Perl OO - Class Data
In general, you can't use objects as keys to a hash.
Given your current usage pattern, I would suggest reversing everything and, instead of $references->{$objref} = "value", try:
That's assuming that no two objects can have the same name. If that's not the case, perhaps you really want arrays:$references->{$objref->{_team}}{$objref->{_name}} = $objref;
Both examples here split everything up by team so that you can just skip over an entire hash or array rather than skipping over individual team members.push @{$references->{$objref->{_team}}}, $objref;
(This is in addition to japhy's advice to use the same variable name to refer to the same object ;-})
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl OO - Class Data
by dsheroh (Monsignor) on Jun 26, 2006 at 16:50 UTC | |
by yoda54 (Monk) on Jun 26, 2006 at 19:14 UTC |