Rather than describing a solution that you can't find, how about describing the problem you are trying to solve. Not the little piece you are having trouble with, but the whole thing.
Well, OK. Since I might run into problems at the far end of it as well, I guess it makes sense to do that. I'm trying to grab a list of all apps registered in the GNOME applications list and convert it to a menu format used by several other window managers. The first format, or at least the parts of it that mean anything, you've already seen (and used in your script); the second one looks like this:
menu Applications folder { menu Editors folder { prog vim vim vim prog Lyx emacs lyx } menu "Mail Agents" folder { prog Mutt mutt xterm -e mutt } menu "WWW Browsers" folder { prog Mozilla mozilla mozilla prog Firefox /usr/share/pixmaps/firefox.png firefox prog Seamonkey /usr/share/pixmaps/firefox.png seamonkey prog w3m lynx xterm -e w3m prog Links lynx xterm -e links } menu Graphics folder { prog Gimp gimp gimp } menu Development folder { prog ddd ddd ddd } prog "Acrobat Reader" pdf acroread prog "DVI Previewer" xdvi xdvi } menu Games folder { prog "Koules for X" koules xkoules -f prog Xboing xboing xboing prog Xboard xboard xboard prog XGalaga xgalaga xgal prog XDemineur xdemineur xdemineur prog ppracer /usr/share/pixmaps/ppracer.xpm /usr/games/ppracer prog Arena arena openarena } ...
Please note that folders (e.g., Applications) can contain other folders (e.g., Editors). Any folder can also contain program entries, which are structured as
prog "Program name" icon.ext executable_name
where the program name must be quoted if it contains whitespace, the icon name must be either a filename or a dash (i.e., no icon), and the executable name can be a PATHed program, an absolute path to a program, or a shell construct to be executed. The menu can contain a few other things, but I'm not concerned with any of those at the moment. The overall problem I'm having is creating the folder/program structure that I want reflected in the menus. That's a chain of categories that terminates in one or more programs belonging in that category - i.e.
menu "Games" folder { menu "GNOME" folder { menu "Action" folder { prog "Arena" arena.png openarena prog "ppracer" /usr/share/pixmaps/ppracer.xpm /usr/game +s/ppracer } } menu "KDE" { ...
If you can help with the overall problem, I'd appreciate it.

In reply to Re^2: Building an arbitrary-depth, multi-level hash by Anonymous Monk
in thread Building an arbitrary-depth, multi-level hash by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.