title: Read and Write in the same file with different process
body: <p>I have written the two program. One program is write the content to the text file simultaneously. Another program is read that content simultaneously. </p>
  
  <p>But both the program should run at the same time. For me the program is write the file is correctly. But another program is not read the file.  </p>
  
  <p>I know that once the write process is completed than only the data will be stored in the hard disk. Then another process can read the data. </p>
  
  <p>But I want both read and write same time with different process in the single file. How can I do that? </p>
  
  <p>Please help me. 
  The following code write the content in the file </p>
  
  <pre><code>sub generate_random_string
  {
      my $length_of_randomstring=shift;# the length of 
         # the random string to generate
  
      my @chars=('a'..'z','A'..'Z','0'..'9','_');
      my $random_string;
      foreach (1..$length_of_randomstring)
      {
          # rand @chars will generate a random 
          # number between 0 and scalar @chars
          $random_string.=$chars[rand @chars];
      }
      return $random_string;
  }
  #Generate the random string
  open (FH,"&gt;&gt;file.txt")or die "Can't Open";
  while(1)
  {
  my $random_string=&amp;generate_random_string(20);
  sleep(1);
  #print $random_string."\n";
  print FH $random_string."\n";
  }
  </code></pre>
  
  <p>The following code is read the content. This is another process</p>
  
  <pre><code> open (FH,"&lt;file.txt") or die "Can't Open";
                print "Open the file Successfully\n\n";
                while(&lt;FH&gt;)
                {
                    print "$_\n";
                }
  </code></pre>