$; = ':'; my %Hash; while (<>) { chomp $_; my ($key, $val) = split(/=/); if ($key =~ /:/) { my @keyparts = split(/$;/, $key); $Hash{ join("$;", @keyparts) } = $val; # I'm not sure how to get perl to not scalar-ize it in this case # But it's probably better to reduce cargo-cultism ;) } else { $Hash{$key} = $val; } } foreach (sort keys %Hash) { print "$_ \t=> " . $Hash{$_} . "\n"; } print $Hash{'a1','b1','c1'} . "\n"