cmikel has asked for the wisdom of the Perl Monks concerning the following question:
then i would like to create a hash of newpackage House; sub new { my $class = shift; my $self = { id => $_[0], name => $_[1], detail => $_[2], }; bless $self, $class; return $self; }
then when a user types a name of the houseroom it can then print the details so something likeuse House; . . . %houserooms = ( kitchen => { House->new("1","kitchen","sleek and modern") } den => { House->new("2","den","board games and more") } ); . . . etc
i am trying to approach this from an OO standpoint. And my thought in hashing objects was that new rooms could be added quickly and this could be built upon by indicating which rooms connect to other rooms. thank you!my $roomcmd = <>; #this def does not print and I am not sure why or how to make it print + the details print $houserooms{$roomcmd}->{detail};
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Use Objects as Hash Values?
by NetWallah (Canon) on Apr 15, 2013 at 05:01 UTC | |
|
Re: Use Objects as Hash Values?
by Athanasius (Archbishop) on Apr 15, 2013 at 08:37 UTC | |
by cmikel (Novice) on Apr 15, 2013 at 13:49 UTC |