# Usage: UsesArrayElementsAsKeyElementsInHash( \%hash, $value, @array ) use Carp; sub UsesArrayElementsAsKeyElementsInHash { my $hash = my $root = ( ref $_[0] ? shift : {} ); my $value = shift; my $last = pop; for my $key ( @_ ) { $hash = ( $hash->{$key} ||= {} ); ref $hash or croak "key = $key\n"; } $hash->{$last} = $value; return $root; }