Perhaps you could discard any lines where the number of zeros exceeds some threshhold that you choose. This will not check for adjacent non-zero values but may be sufficient for your needs.

use strict; use warnings; open my $csvFH, q{<}, \ <<EOD or die qq{open: <<HEREDOC: $!\n}; JOBINIT,2,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 INSAUTH,5,7107,4,9343,5,7716,1,0,3,254,1,0,8,5655,0,0,0,0,0,0,0,0,0,0 INVPSWD,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 INSAUTH,192,440,192,440,188,450,180,450,189,447,192,440,192,440,188,45 +0,152,438,0,0,36,400,192,440 PWDEXPR,4,222,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 INSAUTH,0,0,0,0,0,0,0,0,0,0,5,7107,4,9343,5,7716,1,0,3,254,1,0,8,5655 UNDFUSER,1,0,1,0,3,4199,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 EOD READFILE: while( <$csvFH> ) { chomp; { no warnings q{numeric}; next READFILE if 15 <= grep $_ == 0, split m{,}; } print qq{$_\n}; } close $csvFH or die qq{close: <<HEREDOC: $!\n};

The output.

INSAUTH,5,7107,4,9343,5,7716,1,0,3,254,1,0,8,5655,0,0,0,0,0,0,0,0,0,0 INSAUTH,192,440,192,440,188,450,180,450,189,447,192,440,192,440,188,45 +0,152,438,0,0,36,400,192,440 INSAUTH,0,0,0,0,0,0,0,0,0,0,5,7107,4,9343,5,7716,1,0,3,254,1,0,8,5655

I hope this is helpful.

Cheers,

JohnGG

Update: Fixed code formatting problem caused by a TAB and changed 0s to zeros for readability.


In reply to Re: Remove array if data inconsistent by johngg
in thread Remove array if data inconsistent by meredib

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.