Dear Monks
I have read many things on perl objects and have made a few. But I am perplexed at how to do hashes inside the object.
To give example I want the self hash to have a hash inside it to store things. I would greatly appreciate an example constructor, and get and set methods by key and possibly how to get the hash for internal methods
sub new
{
my $self = {};
#error reporting and update vars
$self->{'error_type'} = undef;
$self->{'error_string'} = undef;
$self->{'text'} = undef;
$self->{'query'} = undef;
$self->{'reference'} = undef;
$self->{'dbh'} = undef;
$self->{'tokens'} = %( how do i do this )
bless ($self);
return $self;
}
sub set_token
{
my $self = shift;
$self->{'token'}{'$_[0]'} = $_[1];
}
sub get_token
{
my $self = shift;
return $self->{'token'}{'$_[0]'};
}
sub get_token_keys
{
my $self = shift;
keys $self->{'token'};
}