The idea is still valid though. it just doesn't replace checks after the data entry.
break up the task
Ensure each new array is internally consecutive
easiest to do at data entry, when you don't have to think about all the other arrays
all the arrays together should hold 0 to #, and no number apears more than once.
after data entry. join the arrays, and sort it, as you are doing now

It adds a step, but doen't add much complexity.

This is assuming that the data is entered within 2 loops, that you can have the the check reset. something like:
my %list; for my $outer=(1..5){ my $last=0; for my $inner=(0..9){ my $number=<STDIN>; unless ($last==0) { unless ($number==$last+1){ die("bad input"); } $list{$outer}[$inner]=$number; } }
Course its very rough code (and probably won't work without tweaking {or a total rewrite}) the principal is there.

In reply to Re: Re: (jeffa) Re: joining and sorting arrays by fuzzysteve
in thread joining and sorting arrays by hotshot

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.