title: Adding an alphabet to last element of array in Perl
body: <p>Script given below cuts input string at every occurrence of "E" and store it in a array. Final output shows all the fragmented strings for every position of "E". But the problem is, this script do not show any "E" in the final element of array in the output, it shows only upto "D". Output Which I'm getting is- </p>
  
  <pre><code>ABCDEABCDE ABCDE ABCDE ABCD
  ABCDE ABCDEABCDE ABCDE ABCD
  ABCDE ABCDE ABCDEABCDE ABCD
  ABCDE ABCDE ABCDE ABCDEABCD
  ABCDE ABCDE ABCDE ABCDE ABCD
  </code></pre>
  
  <p>But final output which I want is-</p>
  
  <pre><code>ABCDEABCDE ABCDE ABCDE ABCDE
  ABCDE ABCDEABCDE ABCDE ABCDE
  ABCDE ABCDE ABCDEABCDE ABCDE
  ABCDE ABCDE ABCDE ABCDEABCDE
  ABCDE ABCDE ABCDE ABCDE ABCDE
  </code></pre>
  
  <p>My script is-</p>
  
  <pre><code>my $s = 'ABCDEABCDEABCDEABCDEABCDE';
  if (substr($s,-1) eq "E") {
      @array1 = @array[0 .. $#array-1];
      print "Results of 1-missed cleavage having 1E at the end\n\n";
      for my $array1 (@array1) {
          substr($s, $array1-1, 1) = "\0";
          my @a = split(/E(?!P)/, $s);
          substr($s, $array1-1, 1) = 'E';
          $_ =~ s/\0/E/g foreach (@a);
          $result = join ("E,", @a); 
          @final = split(/,/, $result);
          print "@final\n";
      }
      my @output=split(/E(?!P)/, $s);
      $out = join ("E,", @output); 
      @output1 = split(/,/, $out);
      print "@output1\n\n";
  }
  else {
      print "E is not at terminal position"
  };
  </code></pre>