text: Q:
  
  How to remove certain Stopwords from a section in a file, which starts and ends with specific characters
  
  .I 1
  .T
  Alice in wonderland
  She follows it down a rabbit hole when suddenly 
  she falls a long way to a curious hall with many locked doors of all sizes. 
  She finds a small key to a door too small for her to fit through.
  .B
  CACM wolf dog December, 1958
  .A
  Perlis, A. J.
  Samelson,K.
  .N
  CA581203 JB March 22, 1978  8:28 PM
  .X
  100 5   1
  123 5   1
  164 5   1
  .I 2
  .T
  Extraction of Roots by Repeated Subtractions for Digital Computers
  the contents of which cause her to shrink too small to reach the key
  which she has left on the table.
  A cake with "EAT ME" on it causes her to grow.
  .B
  CACM December, 1958
  .A
  Sugai, I.
  .N
  CA581202 JB March 22, 1978  8:29 PM
  .X
  2   5   2
  2   5   2
  2   5   2
  Now the above text is the content of 2 files, new file starts from .I (followed by a number)
  i need to do stopping in the text between .T & .B , .B & .A , .A & .N, .N &.X and remove all text between .X and start of new document. i.e. .I (followed by a number)
  "Output should look like"
  .I 1
  .T
  Alice wonderland
  follows rabbit hole suddenly 
  falls long way curious hall locked doors sizes 
  door small fit through
  .B
  CACM wolf dog December, 1958
  .A
  Perlis, A. J.
  Samelson,K.
  .N
  CA581203 JB March 22, 1978  8:28 PM
  .X
  .I 2
  .T
  Extraction Roots Repeated Subtractions Digital Computers
  contents cause shrink
  left table
  cake with EAT causes grow
  .B
  CACM December, 1958
  .A
  Sugai, I.
  .N
  CA581202 JB March 22, 1978  8:29 PM
  .X
  
  i need to do stopping of words on the text which appears between .T & .B , .B & .A , .A & .N, .N &.X
  
  A:
  
  The first step is to get each chunk into a decent data structure. The following script does that. Once you have %segments, you can modify and reassemble each chunk as you wish.
  #!/usr/bin/env perl
  
  use strict; use warnings;
  use Data::Dumper;
  
  my %stops = map { $_ => 1 } qw(a all of in);
  run(\*DATA, \%stops);
  
  sub run {
      my $fh = shift;
      my $stops = shift;
  
      local $/ = '.I';
  
      my $pat = qr{
          ^[ ] (?<I> [0-9]+) \n
          ^[.] T \n (?<T> .+)
          ^[.] B \n (?<B> .+)
          ^[.] A \n (?<A> .+)
          ^[.] N \n (?<N> .+)
          ^[.] X \n (?<X> .+)
      }xms;
  
      while (my $chunk = <$fh>) {
          chomp $chunk;
          next unless $chunk;
  
          if ($chunk =~ $pat) {
              my %segments = %+;
              print Dumper \%segments;
          }
      }
  }
  
  