HiFoo has asked for the wisdom of the Perl Monks concerning the following question:
When I try to access the arrays in the hash using something like:sub new { ... ... $self->{TABLE}{6} = ("4", foo", "was", "here"); $self->{TABLE}{3} = ("3", foo", "was", "here"); ... ... bless ( $self, $class); return $self;
I get the error:my @foo = @{ $self->{TABLE}{6} }; print "$foo[0]\n";
Can't use string ("here") as an ARRAY ref while "strict refs" in use at ./test.pl line x.
and the string in mention is always the last element in the array.
What I don't understand is why I get a scalar value when I think I should be getting an array. Am I incorrectly adding the arrays to the hash or am I doing something else wrong?
Thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Trouble with Hashes of Arrays
by thelenm (Vicar) on Aug 14, 2002 at 19:56 UTC | |
|
Re: Trouble with Hashes of Arrays
by mfriedman (Monk) on Aug 14, 2002 at 20:29 UTC | |
|
Re: Trouble with Hashes of Arrays
by BorgCopyeditor (Friar) on Aug 14, 2002 at 21:08 UTC |