in reply to Re: Find a value from an array in a string
in thread Find a value from an array in a string

Dear Monk, I appreciate your help. I owe you a million. Could you tell me if there may be any other way that I could match the array number to the number located in Sequence 8 on the FT1 line.?? Thanks in advance.
while (<IN>) { chomp(); if (/^(MSH)(.....)/) { setdelimiters($2); } @field = split /$fs/; if ($newblock{$field[0]}) { processbuffer(); } elsif (!$partofblock{$field[0]}) { print STDERR "Possible error: segment=$field[0] line $.\n"; } if ($field[0] eq "FT1") { if ($field[7] == $skipaccount{$_}) { $suppress = 1 if $skipaccount{$field[7]}; } } $buffer .= "$_\n"; } processbuffer(); sub processbuffer { print OUT $buffer unless $suppress; $buffer=""; $suppress = 0; }
MSH|^~\&||||||||||||| EVN||||| PID||||||||||||||||||||| FT1|||||||77413| MEV|||||||||||||||||||

Replies are listed 'Best First'.
Re: Re: Re: Find a value from an array in a string
by Thelonius (Priest) on Mar 13, 2003 at 20:57 UTC
    Instead of:
    if ($field[0] eq "FT1") { if ($field[7] == $skipaccount{$_}) { $suppress = 1 if $skipaccount{$field[7]}; } }
    you just need:
    if ($field[0] eq "FT1") { $suppress = 1 if $skipaccount{$field[7]}; }
    Of course there are a lot of ways to do it--TMTOWTDI