@data starts out with 1 element: "" (the empty string), from when you initialize it.
$data[1],
$data[2],
$data[3], and
$data[4] are all uninitialized.
As you go through the last foreach loop, you (might) assign
$_ to specified elements of @data. On line 49, you print
all the elements of @data - some of which are obviously uninitialized.
You can initalize them with something like the following:
my @data = ('','','','','');
To have it start it's life with 5 empty strings.
Also, consider moving the open/close statemens outside of the
foreach loop.
open STDOUT, ">>", "$output0" or die "$output0: $!\n";
foreach (@list) {
...
print STDOUT, @data;
}
close STDOUT;
Since you're appending to the output file, you might as well
just open it once and be done with it.
Update: Fastolfe pointed out that the initialization
should have been with the empty string instead of undef...thanks.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.