0

Hi....I am very new in perl and maybe My question can be very simple...I created hash of hash and I filled it..

But I cannot access any element of it...This is a part of my code;;

%doclen=($putword=>{id => $words[2]});

Can somebody write any sentensize to access any element of ths hash of hash?...

Thanks

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by mitchems
0

Getting the elements from a has within a hash is fairly easy. I'm not sure exactly what you're trying to do here. More information would be helpful.

$foo{a}->{a}=10;
$foo{a}->{c}="a string";

print "$foo{a}->{a}\n";
print "$foo{a}->{c}\n";

Output:
10
a string

Edited by mitchems: n/a

1

Here's an approach using you code:

@words=("one","two","three","four","five");
$putword="hello";
%doclen=($putword=>{id => $words[2]});

print "$doclen{hello}->{id}\n";

Output:
three

0

BTW, you might check out the code I wrote on the thread "Integrate over two different range and subtract the results of integration and save" and see how I store a hash inside another hash and then passed a reference to a subroutine that dereferenced it. There is a lot of data structure stuff in that script and I think it can help with the idea of a hash inside a hash.

http://www.daniweb.com/forums/thread286658.html

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.