[Israel.pm] hash

Chanan Berler bc.other at gmail.com
Sun Sep 11 05:33:00 PDT 2011


Hello All,

I have a reference to hash structure, and a path where data is found.
Is it possible to retrieve the data where path is found ?


# What I am looking for:
my $hash = {
	'key1' => { 'key11' => 10 },
	'key2' => { 'key21' => { 'key22' => { 'key23' => 100 }}},
	'key3' => { 'key31' => { 'key321' => 20,
							 'key322' => 200 }}
};

# this will not work since it's not referencing to nothing
my $path = {'key3'}->{'key31'}->{'key321'};

# doesn't work for me :-(
print $hash->{$path};

# work (but i wanna use $path as location reference)
print $hash->{'key3'}->{'key31'}->{'key321'};

-- 
===================
----     Chanan Berler    ----
===================


More information about the Perl mailing list