Skyler99 has asked for the wisdom of the Perl Monks concerning the following question:
#!perl -w use strict; my $buffer=""; my $suppress = 0; my @field; my %newline; # my %partofblock; 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, $!"; $newline{$_} = 1 for qw(MSH); while (<IN>) { chomp(); if ($newline{$field[0]}) { processbuffer(); } if ( index($newline{$_}, $skipaccount{$_}) != -1) { $suppress = 1 if $skipaccount{$field[7]}; } $buffer .= "$_\n"; } processbuffer(); sub processbuffer { print OUT $buffer unless $suppress; $buffer=""; $suppress = 0; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Supress a line every time it finds a string
by submersible_toaster (Chaplain) on Apr 08, 2003 at 06:38 UTC | |
|
Re: Supress a line every time it finds a string
by Improv (Pilgrim) on Apr 08, 2003 at 05:05 UTC | |
|
Re: Supress a line every time it finds a string
by CountZero (Bishop) on Apr 08, 2003 at 05:42 UTC |