That's mostly how I've been operating, but I don't like always breaking things down into lists. It's good for algorithms, but you tend to lose structure.

The hmap and hgrep methods seem like a nice way to do that, because when I'm putting things together, it seems like they want to go into a big anonymous structure (multi-level hash). Think of assembling JSON like things for example. In these cases I find it more natural to work with hashes, and hashes of hashes and so forth.

By the answers it seems like the shortest thing is a few lines, which is not overly long, but lacks the super terseness of map or grep. So I think that means I need to write a little function. This isn't so hard, but it does seem that map and grep are so versatile, I was wondering if there were aspects of them I was "not getting", and therefore if there were some ultra-compact expression. It seems like 3 lines is about as short as you can go.

Thanks, Roger

In reply to Re^4: map and grep (but for hashes) by zerohero
in thread map and grep (but for hashes) by zerohero

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.