title: Perl - Insert lines after a match is found in a file
body: <p>I have a file with the following syntax in some_1.xyz</p>
  
  <pre><code>module some_1 {
  INPUT PINS
  OUTPUT PINS
  }
  </code></pre>
  
  <p>and I want to insert APPLY DELAYS xx and APPLY LOADS ld after line module some_1 {</p>
  
  <p>The following code works fine for just one file i.e., if I replace some_1.xyz to *.xyz then the script doesn't work. I tried introducing sleep(xx) but the code doesn't work for multiple files and I could not figure out why it isn't working. Any pointers is appreciated. Thanks</p>
  
  <pre><code>@modulename_array = `grep "module " some_1.xyz | cut -f 2 -d ' '`;
  @line = `grep "module " some_1.xyz`;
  
  chomp(@line);
  chomp(@kfarray);
  
  $i = 0;
  foreach (@modulename_array) {
    print "Applying delay and load to $_.xyz $line[$i] \n";
  
    `perl -ni -le 'print; print "\tAPPLY DELAY xx \n \tAPPLY LOADS  ld\n" if/$line[$i]/' $_.xyz`;
    $i++;
    #sleep(3);
  
  }
  </code></pre>