bartrad:

Sorry about that, I didn't read your code carefully enough, and managed to overlook the initial '.' in your regex, and managed to flub my initial response.

If you're always getting six values and you want to format them as you describe, I don't really see any reason to prefer splitting them up before putting them in the hash versus splitting them up afterwards when you're printing your report.

Generally, I try to let the problem I'm solving guide my choices on building the data structure. If you're doing further processing between the "acquire the data" step and the "report the data" step, then that further processing might be simpler if the data were stored one way vs. storing it the other way. If you don't have an intermediate step yet, but suspect you may in the future, then you might want to put the data in a format suitable for the expected processing if it's no more difficult one way or the other. If there's any extra effort required to put the data in that form and you're not sure you'll use the script again, then you might just put a nice comment in the form of:

# TODO: if we need to jibber the frobnitz, we might want to reform +at the data like # $lag_load{$lag_traffic} = [ [ $inVal1, $outVal1 ], ... ]; # or # $lag_load{$lag_traffic} = [ { in=>$inVal1, out=>$outVal1 }, ... +]; # be sure to update the zig_zag_report subroutine accordingly!

to prompt the future you, if/when the need arises. That way, you don't have to spend the effort unless necessary. Since it's just a comment to give you a little context when you revisit the code, it need not be syntactically perfect--you're just wanting to pass on some ideas to your future self while the code is fresh in your mind.

...roboticus

When your only tool is a hammer, all problems look like your thumb.


In reply to Re^3: Store and print multiple strings by roboticus
in thread Store and print multiple strings by bartrad

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.