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