It may be helpful to review How do I post a question effectively?. There are a few issues that the monks here are having in understanding your question.
  1. The data you have posted does not clearly map to data in memory. I'm guessing that your array initialization code would actually look like:

    my @array = ( 'a[1:0]', 'a[3:2]', 'a[5:4]', );
    but I could be wrong. This is why Anonymous Monk asked you to post your array initialization statement. Because of how you've presented it, my first thought was you has some weird array slice question.
  2. How one maps your dataset to your output is unclear. Again, I could guess at an answer (biggest first number, smallest second number), but that's just a guess. Does every element necessarily look like a[*:*]? You said you "tried with the hash", but it is unclear to me how a hash would solve this issue. Can you post your preliminary code that shows some results?

If I implemented this (based on some wild guesses), I'd use a regular expression in a for loop and cache the max and min in script-level variables. Or possibly use max and min from List::Util in conjunction with maps (e.g. my ($max) = max map /(\d)/, @list;). But this is largely dictated by your spec, which is poorly defined.


#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.


In reply to Re: array question by kennethk
in thread array question by nmm_7280

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.