You chose a good example. I've always found it difficult to come up with any style of concatentation/interpolation that doesn't look cluttered and hard to read. A significant proportion of my bugs are due to this.

As soon as there is any amount of complexity I reach for builtins with parens.

my $str = sprintf( qq{(%s)\n}, join(q{,}, @things), );
Clearly, this is borderline complexity but I've had ternaries, function calls, math (generously seasoned with parens) and the kitchen sink in there as well. I find having a trailing paren to pin the ; to helps me keep things in order. In a word: templates++.

I was disappointed with the book and wish I had bought something else. A two page pdf trying to be a book. I've adopted q, qq, qw and qr but I'm not sure if that was due to advice or my code editor.

And while we're here, you can't have the words "readable" and "uncluttered" alongside the phrase "nested ternaries". However hard people try to format them they're unreadble. Too posh to use a humble if/elsif/else block?

Phew, that's better. :-)


In reply to Re^5: creating hash of hashes from input file (OT: PBP) by wfsp
in thread creating hash of hashes from input file by perlnewbie9292

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.