in reply to Re^4: String comparison in an array
in thread String comparison in an array
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:
does mostly the same as:print "\n$fillarr[0]\t$fillarr[1]\t$fillarr[3]\t$fillarr[4]\t$fillarr[ +5]\t$fillarr[14]\t";
(Still not perfect, but better). Or Text::CSV might also help you write as a tab separated file.print "\n", join "\t", @fillarr[0, 1, 3, 4, 5, 14];
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: String comparison in an array
by newperlbie (Acolyte) on Aug 08, 2018 at 14:16 UTC | |
by Eily (Monsignor) on Aug 08, 2018 at 14:33 UTC | |
by newperlbie (Acolyte) on Aug 08, 2018 at 14:52 UTC | |
by Eily (Monsignor) on Aug 08, 2018 at 14:57 UTC | |
by newperlbie (Acolyte) on Aug 08, 2018 at 15:03 UTC | |
by Marshall (Canon) on Aug 09, 2018 at 21:41 UTC |