#!/usr/bin/perl $CONFIGS={}; &change_struct(string_to_struct("CONFIGS-hosting_plans-c-title"),"ctitle"); print $CONFIGS->{hosting_plans}{c}{title}; exit; sub change_struct { my $struct = shift; $$struct = shift; } sub string_to_struct { my $string = shift; my ($var, $keys) = split /-/, $string, 2; $keys = "-$keys"; # safety check would normally be here - removed for simplicity no strict refs; my $ref = $$var; use strict refs; return deref($ref, $keys); } sub deref { return \$_[0] unless $_[1] =~ s/^-([\w\._]+)//; deref ($_[0]->{$1}, $_[1]); }