I'm trying to provide a tool that will allow a user to create their own control menu. The menu file format is in XML.
In my design, there are 3 types of menu "items" that can be defined. The item's attributes are determined by the item type (command, submenu, separator)
The command that I'm using to read the xml:
use XML::Simple qw(:strict);
XMLin($menufile,forcearray=>['item','command','exec','menu'],keyattr=>
+['name'],suppressempty=>undef);
I expected that all "item"s would be turned into arrays, but that doesn't happen when trying to build the "SoftwareMenu" which only contains other submenus. I get a "Not an ARRAY reference" error. If I add a "blank" item to the SoftwareMenu, the code works.
Any help would be appreciated.
An example of my XML:
<opt>
<menu name="MainMenu">
<label> OPS Menu </label>
<item type="command">
<label> EDM </label>
<exec>
<run> edmBeta </run>
</exec>
</item>
<item type="submenu">
<name> SoftwareMenu </name>
</item>
</menu>
<menu name="SoftwareMenu">
<label> Software Tools </label>
<item type="submenu">
<name> IOCMenu </name>
</item>
</menu>
</opt>
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.