Re: reference to array of hashes in OOP

2007-07-12 Thread Inventor
On Jul 11, 9:04 pm, [EMAIL PROTECTED] (Paul Lalli) wrote:
> If you have access to the server logs, check them.  If not, add this
> line to the top of your program, right under use strict and use
> warnings:
>
> use CGI::Carp qw/fatalsToBrowser/;
>
> Paul Lalli

Thanks Paul, it's nice to have error messages again!

Inventor


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




Re: reference to array of hashes in OOP

2007-07-11 Thread Paul Lalli
On Jul 11, 3:33 pm, [EMAIL PROTECTED] (Inventor) wrote:

> 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.

If you have access to the server logs, check them.  If not, add this
line to the top of your program, right under use strict and use
warnings:

use CGI::Carp qw/fatalsToBrowser/;

Paul Lalli


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




Re: reference to array of hashes in OOP

2007-07-11 Thread Inventor
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.0002 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/




Re: reference to array of hashes in OOP

2007-07-11 Thread Mr. Shawn H. Corey

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.0002 million dollars worth,
   Shawn

"For the things we have to learn before we can do them, we learn by 
doing them."

  Aristotle

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