in reply to Perl OOP
Two alternatives to the hash of hashes way come to mind.
Use an anonymous array ref as your object, and store your two hashes inside that:
package XYZ; use constant { HASH1 => 0, HASH2 => 1, } sub new { my $class = shift; my $self = [ { something => 'this' }, { something_else => 'that' } ]; return bless $self, $class; } sub method { my $self = shift; print $self->[ HASH1 ]{ something }, $self->[ HASH2 ]{ something_els +e }; }
Use Abigail's Inside-out object technique:
package XYZ; my( %instances ); sub new { my $class = shift; my $self = bless \$class, $class; $instances{ $self }{ hash1 } = { something => 'this' }; $instances{ $self }{ hash2 } = { something_else => 'that' }; return $self; } sub method { my $self = shift; my( $hash1Ref, $hash2Ref ) = @instances{ $self }{ hash1, hash2 }; print $hashRef1->{ something }, $hashRef2->{ something_else }; }
|
|---|