I checked our own SuperSearch for this, and it does not seem as though it should be hard, but I cannot seem to figure it out. Maybe it is brain fog. Anyway, consider:
$data{bar}{code} = 'print $foo;'
...
eval $data{bar}{code};
Now what I want to have happen is for eval to say, "uh-oh, $foo is not defined. I will look in $data{bar}{values}{foo} to see if it is there." I'm flexible on my data types, but I want the stuff to be evaluated to just use simple variables.
This is to try to avoid symbolic references. I'm developing code where snippets are found in an XML doc and they refer to tag names so the above might come from
<data name="foo" value="hello" />
<prog>
print $foo;
</prog>
I need it to be as simple as possible to edit the XML so I don't want hash refs there. I want to avoid symbolic refs for the usual reasons.
Any suggestions would, of course, be welcome.
Thanks, --traveler
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.