Here's a complete example of using the Perl vivification module, which you can find on CPAN. Perl's implicit instantiation of hash elements can readily be controlled with fine granularity:
#!/usr/bin/perl -w use Data::Dumper; my $hash = { 'id' => '992609516', 'lat' => '37.7987145', 'lon' => '-122.4436971', 'tag' => { 'operator' => { 'v' => 'CityCarShare' }, 'amenity' => { 'v' => 'car_sharing' }, }, }; print "Id: $hash->{id}\n"; print "Amenity: $hash->{tag}{amenity}{v}\n"; print "Bmenity: $hash->{tag}{Bmenity}{v}\n"; print "Cmenity: $hash->{tag}{Cmenity}{v}\n" if exists($hash->{tag}{Cmenity}{v}); no autovivification 'exists'; print "Dmenity: $hash->{tag}{Dmenity}{v}\n" if exists($hash->{tag}{Dmenity}{v}); no autovivification; print "Emenity: $hash->{tag}{Emenity}{v}\n"; print Data::Dumper::Dumper(\$hash);

$VAR1 = \{ 'lat' => '37.7987145', 'tag' => { 'amenity' => {'v' => 'car_sharing' }, 'operator' => {'v' => 'CityCarShare'}, 'Bmenity' => {}, 'Cmenity' => {}, }, 'lon' => '-122.4436971', 'id' => '992609516' };

In reply to Re: Best Multidimensional Hash Practices? by brycen
in thread Best Multidimensional Hash Practices? by DamianKaelGreen

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.