title: Read text file in Perl word by word instead of line by line
body: <p>I have a big (300 kB) text file containing words delimited by spaces. Now I want to open this file and process every word in it one by one. </p>
  
  <p>The problem is that perl reads the file line by line (i.e) the entire file at once which gives me strange results. I know the normal way is to do something like </p>
  
  <pre><code>open($inFile, 'tagged.txt') or die $!;
  $_ = &lt;$inFile&gt;;
  @splitted = split(' ',$_);
  print $#splitted;
  </code></pre>
  
  <p>But this gives me a faulty word count (too large array?).</p>
  
  <p>Is it possible to read the text file word by word instead?</p>