title: Perl script -- Multiple text file parsing and writing
body: <p>Suppose i have this directory full of text files (raw text). What i need is a <strong><em>Perl script</em></strong> that will parse the directory (up2bottom) text files one by one and save their contents in a new single file, appointed by me. In other words i simply want to create a corpus of many documents. Note: these documents have to be separated by some tag e.g.  indicating the sequence in which they were parsed.</p>
  
  <p>So far i have managed to follow some examples and i know how to read, write and parse text files. But i am not yet in position to merge them into one script and handle many text files. Can you please provide some assistance. thanks</p>
  
  <p><strong>edit:</strong>
  example code for writing to a file.</p>
  
  <pre><code>#!/usr/local/bin/perl
   open (MYFILE, '&gt;&gt;data.txt');
   print MYFILE "text\n";
   close (MYFILE); 
  </code></pre>
  
  <p>example code for reading a file.</p>
  
  <pre><code>#!/usr/local/bin/perl
   open (MYFILE, 'data.txt');
   while (&lt;MYFILE&gt;) {
      chomp;
      print "$_\n";
   }
   close (MYFILE);
  </code></pre>
  
  <p>I've also find out about the <em>foreach</em> function which can be used for tasks as such, but still don't know how to combine them and achieve the result explained in the description.</p>