Have you tried writing any code for that yet? I do understand the question, although the nature of the input is still a bit vague. Are you reading from a file? Is the max value always 31, or will it vary with the input?

If I had to code something like that, the plan would be:

use strict; use warnings; # get the inputs into an array, one "number" or "n:n" range per array +element. # then: my @covered; # an array to track the "coverage" of the inputs # for each input array element { # if the element does not contain ":" # use it as an array index and set $covered[$element] to some va +lue # otherwise # split on ":", sort the pieces numerically and assign to $begin +, $end # $covered[$_] = 'some value' for ( $begin .. $end ); # } # Once that's done, the only thing left to do is: my $uncovered = ''; for ( 0 .. $#covered ) { $uncovered .= "$_, " unless ( defined( $covered[$_] )); } $uncovered =~ s/, $/\n/; print $uncovered;
That output would not exactly match what you said you wanted, but I'm puzzled why you would want your output to be so irregular (some elements shown as single values, some shown as ranges, some ranges have higher value first, etc).

If you really want your output to be as complicated as you say in the OP, go ahead and try writing some code to do that. If it doesn't work and you can't figure out how to fix it, post another thread, and show us what you tried.


In reply to Re: screen out an untained array from a special array by graff
in thread screen out an untained array from a special array by Hanken

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.