title: Perl split with empty text before/after delimiters
body: <p>I was noticing some curious behavior with Perl's split command, particularly in cases when I would expect the resulting array to contain empty strings '', but it actually doesn't.</p>
  
  <p>For example, if I have a delimiter(s) at the end (or the beginning) of the string , the resulting array does not have an empty string(s) '' as the last (or first) element.</p>
  
  <p>Example:</p>
  
  <pre><code>@s = split(/x/, 'axb')
  </code></pre>
  
  <p>produces 2 element array ['a','b']</p>
  
  <pre><code>@s = split(/x/, 'axbx')
  </code></pre>
  
  <p>produces same array</p>
  
  <pre><code>@s = split(/x/, 'axbxxxx')
  </code></pre>
  
  <p>produces same array</p>
  
  <p>But as soon as I put something at the end, all those empty strings do appear as elements:</p>
  
  <pre><code>@s = split(/x/, 'axbxxxxc')
  </code></pre>
  
  <p>produces a 6 element array ['a','b','','','','c']</p>
  
  <p>Behavior is similar if the delimiters are at the beginning.</p>
  
  <p>I would expect empty text between, before, or after delimiters to always produce elements in the split. Can anyone explain to me why the split behaves like this in Perl? I just tried the same thing in Python and it worked as expected.</p>
  
  <p>Note: Perl v5.8</p>