OK, so here are my responses.
  1. @cur_spin == $row_length: this was in fact a bug in my code, i.e. it checked it, then added to @cur_spin ... I fixed it by changing the $row_length to 15*159+1. Although I think both of the versions above will probably be more efficient, I want to use a working version of my original code as a baseline.

  2. Golfing: Hm, well, although there are really no departmental or corporate coding standards for perl, I'm trying to go by a sensible guideline. It's most likely someone's going to try to use my code in the future, and my department doesn't really use perl, so they'd be learning it on the fly. I'd rather leave code that makes sense to them, not only as a service to them, but also so they might be interested in using perl themselves. That said, since the concept of major and minor frames is something the rest of my coworkers use regularly, I'm going with a shortened but not too short format of $major and $minor.

  3. Indices are not necessarily numeric, so I can't optimize that. I wish I could, but there are other anonymous hashes I put in $ref_data that are specific to each frame, but are indexed by a alphanumeric string, not a number. I need these hashes for other data analysis subroutines.

  4. Wonky logic... Yup, I know some of that needs explaining. The third minor frame data being equal to 165 and each row starting at a multiple of 10 is something I (or, well, my customer) knows about the data. I know it's somewhat arbitrary, and put in comments to that effect. As requirements may change in the future, this is the sort of thing I'm figuring on including later on, writing code to read in parameters from a config file using Getopt::Long, creating a hash that would be accessed as needed.

  5. sorting results: Yes, that was another bug, albeit a minor one, which I fixed. Thanks for pointing that out.

  6. From xdg's post -
    This kind of assumes that you can generate a row name in a subroutine from the row itself other than with all those indexes.
    -------------------
    Hm, since the output of find_row_name would simply be $filename,$major," . $minor++, I'm not sure if it increases the readability that much.

    If you really want/need the indexes, then you'll have to do something more like what you've got with all the indices and looping instead of the way I've done it with map.
    -------------------
    Maybe. I do like this algorithm, but the only thing is, I need the value of each key where a row starts, i.e. each minor frame key and each major frame key. Especially since these keys are not necessarily sequential, nor are the same as the corresponding values of each key, as you say, I need to iterate as I do in my original code.


In reply to Re: Refactoring nested if block by bowei_99
in thread Refactoring nested if block by bowei_99

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.