title: Combining two one line Perl commands into a script
body: <p>I am trying to combine the following two one line perl codes into a single perl script that carries out both on a line of a file before progressing to the next line. Note that this is not my own original code, it was very thoughtfully provided here: <a href="https://stackoverflow.com/questions/14345198/adding-a-blank-line-between-unrelated-data-entries/14345412?noredirect=1#comment19941944_14345412">Adding a blank line between unrelated data entries</a></p>
  <h1>1</h1>
  <pre><code>perl -pae 'print $/ if (defined $x &amp;&amp; $x ne $F[0]); $x = $F[0];' DF-data2pfa.csv &gt;DF-data2pfb.txt
  </code></pre>
  <h1>2</h1>
  <pre><code>perl -pae 'print $/ if (defined $x &amp;&amp; $x ne $F[3]); $x = $F[3];' DF-data2pfb.txt &gt;DF-data2pfc.txt
  </code></pre>
  <p>The script does exactly what I want it to (compares the <code>F[0]</code> field of a line in my dataset to the <code>F[0]</code> of the previous line and adds a blank line between those entries if they are different), except I realized that I need it to look at <code>F[0]</code> and <code>F[3]</code> on a single line and compare both to the previous line. Much to my embarrassment I tried just running one after another, and did not realize that this was adding an extra blank line every time the script encountered the blank line added by the previous script, which is unacceptable to the program I am trying to input this data to.</p>
  <p>So I tried using the <code>Deparse</code> tool to convert both into script format and than use an <code>elsif</code> statement to add the second to the first. This became messy. Also I'm not sure how to achieve the <code>pae</code> function of the command line in the script. I'm not sure the <code>e</code> is necessary in the script but it seems like first printing each line and then splitting it into an array ( with <code>pa</code> ) is a rather integral component to this whole code and I'm not sure how to achieve that here.</p>
  <p>Here's what I got:</p>
  <pre><code>while (defined($_ = &lt;ARGV&gt;)) {
      our(@F) = split(' ', $_, 0);
  $x = $F[0];
  $y = $F[3];
  if defined $x and $x ne $F[0];
  elsif defined $y and $y ne $F[3];
     print $/ 
  }
  continue {
      die &quot;-p destination: $!\n&quot; unless print $_;
  }
  </code></pre>
  <p>I'm also open to not using the <code>deparse</code> module if that's unnecessary here. Thanks for any help/explanations you can provide!</p>