Homework or not, this is too nice a problem to resist to show the beauty of Text::CSV_XS. Sorry.

use 5.18.2; use warnings; use Data::Peek; use Text::CSV_XS qw( csv ); my @f = ("A".."R"); csv (in => "file.csv", headers => \@f, filter => { A => sub { if ($_ eq "2323" && $_{O} ne "AA") { $_[0]->say (*STDERR, [ "ERROR", @_{@f} ]); return 0; } $_ ne "0000" && $_ ne "1111" && $_ ne "2222"; }, O => sub { if ($_ eq "BC") { $_[0]->say (*STDERR, [ "ERROR", @_{@f} ]); return 0; } 1; } }, on_in => sub { $_{D} =~ tr/+=/ /; $_{A} =~ s/^1212$/a/; $_{A} =~ s/^2121$/aa/; $_{A} =~ s/^3131$/ba/; $_{A} =~ m/^(?:6767|9898|5656)$/ && $_{D} =~ m/90 09/ and $_{ +G} = "AA"; }, );

I tested that with

A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R 1,2,3,4,5,6,7,8,9,0,a,b,c,d,e,f,g,h A,B,C,foo + bar = F,E,F,G,H,I,J,K,L,M,N,O,P,Q,R A,B,C,D,E,F,G,H,I,J,K,L,M,N,BC,P,Q,R 0000,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R 1111,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R 2222,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R 2323,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R 2323,B,C,D,E,F,G,H,I,J,K,L,M,N,AA,P,Q,R 1212,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R 2121,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R 3131,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R 6767,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R 6767,B,C,D09 09D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R

=>

ERROR,A,B,C,D,E,F,G,H,I,J,K,L,M,N,BC,P,Q,R ERROR,2323,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R 1,2,3,4,5,6,7,8,9,0,a,b,c,d,e,f,g,h A,B,C,"foo bar F",E,F,G,H,I,J,K,L,M,N,O,P,Q,R 2323,B,C,D,E,F,G,H,I,J,K,L,M,N,AA,P,Q,R a,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R aa,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R ba,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R 6767,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R 6767,B,C,"D09 09D",E,F,G,H,I,J,K,L,M,N,O,P,Q,R

Enjoy, Have FUN! H.Merijn

In reply to Re: Perl: Syntax Errors, Help Needed by Tux
in thread Perl: Syntax Errors, Help Needed by Novice_Monk23

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.