Something like the following?
#!/usr/bin/perl -w
use strict;
my %test_hash;
$test_hash{'a'}{'b'}{'c'}{'d'} = "Yay";
print get_id("a.b.c.d"), "\n";
sub get_id
{
my @parts = split /\./, $_[0];
# Currently written to access a global hash
return $test_hash{$parts[0]}{$parts[1]}{$parts[2]}{$parts[3]};
}
I'm sure other monks can find more efficient (or bulletproof) ways. But this seems to work -- you could probably easily alter it so that it accepts a reference to a particular hash and uses that inside the sub.
Also note that $hash{'a'}{'b'}{'c'} is the same as $hash{'a'}->{'b'}->{'c'}