[b][red]This message was edited by saridski at 2006-9-1 13:5:58[/red][/b][hr]
I am getting this:
Can't use string ("thrA") as a HASH ref while "strict refs"
On this line:
...
foreach (sort keys %GENES) {
print(F_OUT " >$_|");
print(F_OUT $_->{LOCATION});
#HERE}
...
The KEY is actually a string type, in this case "thrA". How do I kill this error w/o removing use strict?
Thanks in advance!
Comments
: I am getting this:
:
: Can't use string ("thrA") as a HASH ref while "strict refs"
:
: On this line:
:
: ...
: foreach (sort keys %GENES) {
: print(F_OUT " >$_|");
: print(F_OUT $_->{LOCATION}); #HERE
: }
: ...
:
: The KEY is actually a string type, in this case "thrA". How do I kill this error w/o removing use strict?
:
: Thanks in advance!
:
Maybe I'm missing something from the code surrounding the snip you provided but here goes what I see.
You're using $_ as a ref to hash %GENES when $_ is really the key. So you should be printing something like this:
print F_OUT %GENES->{$_};
X
foreach (sort keys %GENES) {
print(F_OUT " >$_|");
print(F_OUT $GENES{$_}{LOCATION});
}
[/size][/code]
: foreach (sort keys %GENES) {
: print(F_OUT " >$_|");
: print(F_OUT $GENES{$_}{LOCATION});
: }
: [/size][/code]
:
Thanks to you both for your responses.
Yes, I am using the default variable when Iterating the hash.
Well done Kevin, works well. LOCATIONS is indeed an array and I think it's there I went wrong. I was trying to access it as if it was a hash when in fact, I was attempting to access an array.
Here is how the structure is built:
push(@{%GENES->{$_}->{LOCATIONS}}, ({LOCATION => $_[0], DNA => undef}));
Thanks very much.