Request to check: Not printing all entries

Dear all,

I am facing one problem

in my input file there are many Entries which starts from *FIELD * AV (checked the attached file)

I want all the entries in the output file which start from
*FIELD * AV

I have written this programm but its not printing all the entries with *FIELD * AV

Its missing certain entries please correct the programm ond checked sample of attached input file.

#!/usr/bin/perl
open(DATA,'mutationsonly.txt');
# or die("Could not open mutationsonly file.");
open(MYOUTPUT, ">newmutations.txt");
# or die ("could not open newmutations file.");
$/="\n\n";
my @records = <DATA>;
foreach my $record (@records)
{
my $line =~m/^\*FIELD\*\sAV$/;
if ($record =~ m/ ($line) /) 
  {
print "$record";
   }
}
 
close(MYOUTPUT);
close(DATA);

try the below for loop

 
foreach my $record (@records)
{
if ($record =~ /^\*FIELD\*\sAV$/)
{
print "$record";
}
}

---------- Post updated at 02:37 PM ---------- Previous update was at 02:36 PM ----------

 
perl -lane 'print $_ if ($_=~/\*FIELD \* AV/)' mutationsonly.txt

Hi

Thanks for reply.

Now the outputfile is completely blank

perl -lane 'print $_ if ($_=~/\*FIELD \* AV/)' mutationsonly.txt >output.txt*

I used this and there is and the output file is blank no entry at all even using the other programm as well.

Please guide if somebody can

untill you show the input data, i cannot help :frowning:

Hi Kamraj

Input data is in attached file named sample.input which is part of very very big input file. Kindly check it in my first post itself. I am attaching here again

Mani