My apologies for the bad title. It's already taken me 30 minutes to come up with that! ;)

I use this a lot: (Very cool IMHO)

@hash{a..z}=(1..26)

What I'd really like to see though is something like this:

$hash{a..c}='some value'

Where the results would be equivalent to:

$hash{a}{b}{c}='some value'

Is there a cleaver way of doing this that would add the items. I had a subroutine (misplaced it) that would reverse the tree 'c'..'a' when passed 'a'..'c', loop on it, build a hash 'c'=>'some value', place that hash in 'b'=>{'c'='somevalue'} and finally 'a'=>{'b'=>{'c'='somevalue'}.

Obviously, if I ran the sub a second time with, (a,b,d)='another value', the 'b' branch (and 'a' for that matter) would be completely over-written. I'm not seeing the solution. Please help! 8)

All help will be greatly appreciated!
Shawn M Ferris
Oracle DBA


In reply to A hash slice but not.. by smferris

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.