my $base = substr($grp, 0, 3); if (exists $is_hierarchy{$base}) { $dsc{$base}{$grp} = $dsc; $title = "$base$ng"; } else { $dsc{other}{$grp} = $dsc; }