If I had to code something like that, the plan would be:
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).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;
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |