in reply to Tab completion in a shell

Well, in one way or other you'll have to. You might like to use something like this: $attribs->{completion_word} = [ map /([^:]+):.*\b\Q$menu\E\b/, @commands ]; Now you can write elements of @command as 'command: menu1 menu2 menu3' where menu1, menu2, menu3 etc are menu names. Provided the menu name is stored in $menu, the regex will filter the appropriate entries and provide the first part in front of the colon as command name. In your example you could have something like an 'nfs: main network' element.

Makeshifts last the longest.