Chady's reply (with Skeeve's amendment) basically shows you the code that you're trying for. To elaborate a little more on his brief comment:

Your code as originally posted contained the start of at "for" loop (near the end) that was never terminated. (That was the only syntax error that made it impossible to run.)

But apart from that, your use of "select" in the last "for" loop is quite wasteful and unnecessary -- when you want to write to a specific file, just use the file handle in the print statement:

open( OUT, ">file.name" ) or die "can't write to file.name:$!"; print OUT "Line $_ : [$line[$_]]\n" for (0..$#line); close OUT;
Your various statement labels and goto's were unnecessary as well -- again, don't use such things when you don't have to.

Also, as Chady demonstrated, your array initialization does not require all the typing you did in your original code -- and you don't need to do anything to initialize the size of an array -- Perl will grow the array for you as you assign values to array elements, and there are many ways to declare an initial set of array values with relatively little typing.


In reply to Re: An easier way to construct lists of numbers? by graff
in thread An easier way to construct lists of numbers? by stu96art

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.