title: How to merge diff result between two files into a third file?
body: <p>I am trying to write a Perl script that will do the following:
  compare two files with the same name from different source dirs, meaning:</p>
  
  <pre><code>diff source_dir_1/file_1 source_dir_2/files_2
  </code></pre>
  
  <p>and for each changed line in file_2 (compared to file_1) it will find the line from file_1 (that has been changed in file_2) at a third file: source_dir_3/file_3, and replace this line with the line from file_2.</p>
  
  <p>For example, for:</p>
  
  <p><strong>file_1:</strong></p>
  
  <blockquote>
    <p>My name is Shahar<br>
    Hello World<br>
    Nice to meet  </p>
  </blockquote>
  
  <p><strong>file_2</strong></p>
  
  <blockquote>
    <p>My name is Shahar<br>
    Goodbye World<br>
    Nice to meet</p>
  </blockquote>
  
  <p><strong>file_3:</strong></p>
  
  <blockquote>
    <p>This line can be different<br>
    Hello World<br>
    Nice to meet</p>
  </blockquote>
  
  <p>The resulting file_3 will be:</p>
  
  <p><strong>file_3_after_script:</strong></p>
  
  <blockquote>
    <p>This line can be different<br>
    Goodbye World<br>
    Nice to meet</p>
  </blockquote>
  
  <p>I'm having a problem with writing it, because sometime one line in file_1 will be replaced with several lines in file_2,</p>
  
  <p>Do you have any suggestions about how I should approach this problem?</p>