Improv makes some valid points, I'll render them down to - 'This code is difficult to interpret' , by humans and perl alike it would seem.

So lets, get forensic on it. You initialising some funky stuff here, some of it looks like you plan to add to it later.

#!perl -w use strict; my $buffer=""; my $suppress = 0; my @field; my %newline; $newline{$_} = 1 for qw(MSH); my %skipaccount; $skipaccount{$_} = 1 for qw(77403 77404 77406 77407 77408 77409 77411 +77412 77413 77414 77416 77418); my $infile = 'c:/rx_q.008'; my $outfile = 'c:/ftpscript/idxfile.txt'; open IN, "<$infile" or die "Couldn't open $infile, $!"; open OUT,">$outfile" or die "Couldn't open $outfile, $!"; while (<IN>) {
# Ok now $_ has scalar input from <IN>
chomp();
# and it's newline chomped # here is where it is confusing, there is nothing in @field, # let alone at $field[0] , do you mean to split up $_ into @field ???
if ($newline{$field[0]}) { processbuffer(); }
# OK , I am certain this is not doing what you expect #if ( index($newline{$_}, $skipaccount{$_}) != -1) { # $suppress = 1 if $skipaccount{$field[7]}; #} # What you're aiming at (IMHO) is to set suppress to 1 if # the item at index 7 in your fields array (which is split from $_ ri +ght??) # is a member of the skipaccount hash. # the if (index($newline{$_} ) makes no sense to me, not in the least + with # the data that appears to be in those objects.
$buffer .= "$_\n"; } # Personally I prefer calling functions like this with an arg, rather +than # relying on a globar ($buffer in this case). processbuffer(); sub processbuffer { print OUT $buffer unless $suppress; $buffer=""; $suppress = 0; }

I can't believe it's not psellchecked

In reply to Re: Supress a line every time it finds a string by submersible_toaster
in thread Supress a line every time it finds a string by Skyler99

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.