There are quite a lot of things to correct here... I'll only point out some of thems because otherwise I'll just end up rewriting everything, and I'd rather leave you with your own code, but feel free to post the cleaned up version again if you want more advice.

First, you might notice that you open two files using two different methods. The second one - where you use a variable with a $, and indicate that the file is for reading with < - is the one to use. The first one is especially bad because DATA is already used by perl to mean something else, so you should really avoid it.

Second, a short and working example is supposed to be short. Remove all the commented lines that make it really hard to read your code (you should keep the useful comments, like # need to change this loop)

Third, this:

print "\n$fillarr[0]\t$fillarr[1]\t$fillarr[3]\t$fillarr[4]\t$fillarr[ +5]\t$fillarr[14]\t";
does mostly the same as:
print "\n", join "\t", @fillarr[0, 1, 3, 4, 5, 14];
(Still not perfect, but better). Or Text::CSV might also help you write as a tab separated file.

Fourth: you can remove the else { next; } because next basically means "stop working on that element", but there's no work to be done at that point (nothing after the else).

Fifth: just including a module doesn't magically solve your problems. You can create your reader like this: my $csv = Text::CSV->new ({ binary => 1, sep_char => ";" }); and then use the parse() and fields() method to get your arrays. Or if you don't want to use Text::CSV, don't include it.


In reply to Re^5: String comparison in an array by Eily
in thread String comparison in an array by newperlbie

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.