I've got a rather perplexing problem.

I have a complex data structure, say:
$configs{images}{attach}{file}="height=19 width=15 src='/images/attach +/file.gif' border=0"; $configs{images}{attach}{URL}="height=19 width=15 src='/images/attach/ +URL.gif' border=0"; $configs{images}{attach}{edit}="height=19 width=15 src='/images/attach +/edit.gif' border=0"; $configs{mime_map} = MY::PATH::_get_mime_map ();
and later on: (although you shouldn't need it to answer this question)
sub _get_mime_map { my $mime_map = { '' => ["application/octet-stream","Unknown binary form +at"], # BEGIN these are non-standard 'aw' => ["application/applix","Applix Word Document"], 'as' => ["application/applix","Applix Spreadsheet"], 'ag' => ["application/applix","Applix Graphic"], # END these are non-standard 'ai' => ["application/postscript","Postscript ai File" +], 'aif' => ["audio/x-aiff","Aif File"], 'asc' => ["text/plain","ASCII Text File"] return($mime_map); }
I want to be able to call $configs->{image}{attach}{$mime_type} and have the html for it presented.
OK, now the problem is, I do NOT want to have to add a $configs{image}{attach} for each mime_type (there are plenty more, as you can imagine).

How can I tell $configs that if a {image}{attach}{UNKNOWN} is called that it doesn't know about, to create one with the same text as the others, but with the image file (at the end of the text) being the same as the missing (UNKNOWN) name (with .gif added)?
Hopefully I am presenting this clearly.

This is all being done in modules, mind you, with $configs being a common object to all the modules.

Any help would be appreciated.

What does this little button do . .<Click>; "USER HAS SIGNED OFF FOR THE DAY"

In reply to Method autovivification with variable values? by tame1

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.