title: Attach frequent words in text file
body: <p>I have two files. The first contains frequent
  word sequences
  extracted from a text file</p>
  <h3>a.txt :</h3>
  <pre><code>big pizza
  eat big pizza 
  ...
  </code></pre>
  <p>the text file is</p>
  <h3>b.txt :</h3>
  <pre><code>i eat big pizza .my big pizza ...
  </code></pre>
  <p>My problem is to add <code>bbb</code> between words from each sequence that exist in file <code>a.txt</code> and write a new file .
  so the result will be</p>
  <pre><code>i eatbbbbigbbbpizza.my bigbbbpizza...
  </code></pre>
  <p>below is my script. It adds <code>bbb</code> only between pairs 9f words. How can I correct this?</p>
  <pre><code>use strict;
  use warnings;
  use autodie;
  
  my ($f1, $f2) = ('a.txt', 'b.txt');
   
  open( my $fh, $f1 );
  
  my @seq;
  
  foreach ( &lt;$fh&gt; ) {
    chomp; 
    s/^\s+|\s+$//g; 
    push @seq, $_;      
  }
  close $fh;
   
  open($fh, $f2);
  
  foreach (&lt;$fh&gt; ) {
      foreach my $r (@seq) {   
          my $t = $r =~ s/ /bbb/r; 
          if (/$r/) {
              s/$r/$t/g;
          }
      }
      print ;
  }
  close $fh;
  </code></pre>