On Jul 11, 5:09 pm, [EMAIL PROTECTED] (Mr. Shawn H. Corey) wrote:
> Inventor wrote:
> > Hi,
>
> > I would like to make a perl module with an array of hashes as the data
> > structure, but I am having trouble with the references.  I have
> > declared the data structure in the constructor as follows:
>
> >     my $self = ({});
>
>    my $self = [];
>
>
>
> > and blessed it with:
>
> >     bless ($self, $class_name);
>
> > but when I try to access the array of hashes, for example with:
>
> >         $self->[$index]{'team1'} = $words[0];
>
> # This will work even if you don't put any hashes in the array.  If the
> hash doesn't exists, Perl will create it.
>
>
>
> > the program gets a run-time error, and I don't know which error
> > message it is because the module is used in a CGI program and I don't
> > know how to get at the error messages.  What should i do?  Am i doing
> > it all wrong?  Thanks in advance.
>
> > Inventor
>
> --
> Just my 0.00000002 million dollars worth,
>     Shawn
>
> "For the things we have to learn before we can do them, we learn by
> doing them."
>    Aristotle

Thank you Shawn, that is just what I needed.  Further, I learned that
referencing the array of hashes is done like this:

    return $self->[$index]{$key};

which works nicely.  Thanks a bunch!

inventor




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to