my @array = ( 'Main//News', 'Main//Reviews//PC', 'Main//Reviews//PS2', 'Main//Reviews//XBox', 'Other Menu//Other//Sub//Menus' ); my %hash; foreach (@array) { s|(\w+\s+\w+)|\'$1\'|g; s|\/\/|\}\{|g; eval '$hash{' . "$_" . '} = 1'; } sub build { my $hash = shift(); while (my ($key, $value) = each %$hash) { if (ref $value eq 'HASH') { $html .= "
  • $key