title: What produces the white space in my perl programm?
body: <p>As the title says, I have a program or better two functions to read and write a file either in an array or to one.  But now to the mean reason why I write this: when running my test several times my test program that tests my functions produces more and more white space.  Is there somebody that could explain my fail and correct me?</p>
  
  <p>my code</p>
  
  <p>Helper.pm:</p>
  
  <pre><code>#!/usr/bin/env perl
  
  package KconfCtl::Helper;
  
  
  sub file_to_array($) {
      my $file = shift();
      my ( $filestream, $string );
      my @rray;
  
      open( $filestream, $file ) or die("cant open $file: $!");
      @rray = &lt;$filestream&gt;;
      close($filestream);
      return @rray;
   }
  
  
  sub array_to_file($$;$) {
      my @rray = @{ shift() };
      my $file = shift();
      my $mode = shift();
      $mode='&gt;' if not $mode;
      my $filestream;
  
      if ( not defined $file ) {
          $filestream = STDOUT;
      }
      else {
          open( $filestream, $mode, $file ) or die("cant open $file: $!");
       }
      my $l = @rray; print $l,"\n";
      foreach my $line (@rray) {
        print $filestream "$line\n";
      }
      close($filestream);
  }
  
  
  
  1;
  </code></pre>
  
  <p>test_helper.pl:</p>
  
  <pre><code>use KconfCtl::Helper;
  use strict;
  my @t;
  @t= KconfCtl::Helper::file_to_array("kconf.test");
  #print @t;
  my $t_index=@t;
  @t[$t_index]="n";
  KconfCtl::Helper::array_to_file(\@t, "kconf.test", "&gt;");
  </code></pre>
  
  <p>the result after the first:</p>
  
  <pre><code>n
  </code></pre>
  
  <p>and the 2nd run:</p>
  
  <pre><code>n
  
  n
  </code></pre>